Skip to content

Commit ec286ff

Browse files
committed
adde dmore error catching
1 parent 60738d2 commit ec286ff

File tree

3 files changed

+1327
-1318
lines changed

3 files changed

+1327
-1318
lines changed

android/src/main/java/land/fx/fula/FulaModule.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -739,17 +739,26 @@ public void writeFile(String fulaTargetFilename, String localFilename, Promise p
739739
ThreadUtils.runOnExecutor(() -> {
740740
Log.d("ReactNative", "writeFile to : path = " + fulaTargetFilename + ", from: " + localFilename);
741741
try {
742-
land.fx.wnfslib.Config config = Fs.writeFileFromPath(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), fulaTargetFilename, localFilename);
743-
if(config != null) {
744-
this.rootConfig = config;
745-
this.encrypt_and_store_config();
746-
if (this.fula != null) {
747-
this.fula.flush();
742+
if (this.client != null) {
743+
Log.d("ReactNative", "writeFileFromPath started: this.rootConfig.getCid=" + this.rootConfig.getCid()+ ", fulaTargetFilename="+fulaTargetFilename + ", localFilename="+localFilename);
744+
land.fx.wnfslib.Config config = Fs.writeFileFromPath(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), fulaTargetFilename, localFilename);
745+
if(config != null) {
746+
this.rootConfig = config;
747+
this.encrypt_and_store_config();
748+
if (this.fula != null) {
749+
this.fula.flush();
750+
promise.resolve(config.getCid());
751+
} else {
752+
Log.d("ReactNative", "writeFile Error: fula is null");
753+
promise.reject(new Exception("writeFile Error: fula is null"));
754+
}
755+
} else {
756+
Log.d("ReactNative", "writeFile Error: config is null");
757+
promise.reject(new Exception("writeFile Error: config is null"));
748758
}
749-
promise.resolve(config.getCid());
750759
} else {
751-
Log.d("ReactNative", "writeFile Error: config is null");
752-
promise.reject(new Exception("writeFile Error: config is null"));
760+
Log.d("ReactNative", "writeFile Error: client is null");
761+
promise.reject(new Exception("writeFile Error: client is null"));
753762
}
754763
} catch (Exception e) {
755764
Log.d("get", e.getMessage());

example/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ const App = () => {
3131
console.log(err.message, err.code);
3232
});
3333
};
34-
//Key for peerId: 12D3KooWDPZGpr4Jeq144R2KhezH7UHgHqyMXySh8tA5jzUyu2P8
34+
//Key for peerId: 12D3KooWFi2PK36Rzi4Bmosj1np2t6i9v3QnbBiNY9hQWuJajnmZ
3535
const privateKey = [
3636
183, 7, 117, 9, 159, 132, 170, 235, 215, 34, 145, 181, 60, 207, 4, 27, 27,
3737
17, 17, 167, 100, 89, 157, 218, 73, 200, 183, 145, 104, 151, 204, 142, 241,
3838
94, 225, 7, 153, 168, 239, 94, 7, 187, 123, 158, 149, 149, 227, 170, 32, 54,
3939
203, 243, 211, 78, 120, 114, 199, 1, 197, 134, 6, 91, 87, 152,
4040
];
4141
const privateKeyString = "\\test";
42-
const bloxAddr = '/dns/relay.dev.fx.land/tcp/4001/p2p/12D3KooWDRrBaAfPwsGJivBoUw5fE7ZpDiyfUjqgiURq2DEcL835/p2p-circuit/p2p/12D3KooWQR2XygKM7jhBduhvz2GDJdGEbZL8SZhkeBuXYPn2kRt6';
42+
const bloxAddr = '/dns/relay.dev.fx.land/tcp/4001/p2p/12D3KooWDRrBaAfPwsGJivBoUw5fE7ZpDiyfUjqgiURq2DEcL835/p2p-circuit/p2p/12D3KooWLGatFxDzMrKd4S6UC4GAtuM4zcFJW8RPuMR9SH7j46A8';
4343
const newClient = async () => {
4444
try {
4545
return fula.newClient(

0 commit comments

Comments
 (0)