Realm.open and Realm.openAsync should try/catch opening the realm

and pass the error on to the promise and callback respectively so that it can be handled by the caller
This commit is contained in:
Yavor Georgiev 2017-07-11 17:25:39 +02:00
parent 1e58351ace
commit b1d23bb782
No known key found for this signature in database
GPG Key ID: 83FC145DA0CCA9C3
1 changed files with 14 additions and 6 deletions

View File

@ -49,9 +49,13 @@ module.exports = function(realmConstructor) {
reject(error);
}
let syncedRealm = new realmConstructor(config);
//FIXME: RN hangs here. Remove when node's makeCallback alternative is implemented
setTimeout(() => { resolve(syncedRealm); }, 1);
try {
let syncedRealm = new this(config);
//FIXME: RN hangs here. Remove when node's makeCallback alternative is implemented
setTimeout(() => { resolve(syncedRealm); }, 1);
} catch (e) {
reject(e);
}
});
});
},
@ -62,9 +66,13 @@ module.exports = function(realmConstructor) {
callback(error);
}
let syncedRealm = new realmConstructor(config);
//FIXME: RN hangs here. Remove when node's makeCallback alternative is implemented
setTimeout(() => { callback(null, syncedRealm); }, 1);
try {
let syncedRealm = new this(config);
//FIXME: RN hangs here. Remove when node's makeCallback alternative is implemented
setTimeout(() => { callback(null, syncedRealm); }, 1);
} catch (e) {
callback(e);
}
});
},
}));