js: cleanup error util
This commit is contained in:
parent
a3f3cf930a
commit
51c63b2f3e
|
@ -132,11 +132,17 @@ export default class Reference extends ReferenceBase {
|
|||
})
|
||||
.catch((error) => {
|
||||
const firebaseError = this.db._toFirebaseError(error);
|
||||
if (isFunction(failureCallback)) failureCallback(firebaseError);
|
||||
if (isFunction(failureCallback)) return failureCallback(firebaseError);
|
||||
return Promise.reject(firebaseError);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param eventType
|
||||
* @param origCB
|
||||
* @returns {*}
|
||||
*/
|
||||
off(eventType?: string = '', origCB?: () => any) {
|
||||
const path = this._dbPath();
|
||||
const modifiersString = this.query.getModifiersString();
|
||||
|
|
|
@ -9,8 +9,15 @@ const _handler = (resolve, reject, errorPrefix, err, resp) => {
|
|||
setImmediate(() => {
|
||||
if (err) {
|
||||
const firebaseError = new Error(err.message);
|
||||
firebaseError.code = toWebSDKErrorCode(err.code || err.errCode || err.errorCode || '', errorPrefix);
|
||||
return reject(errorPrefix ? firebaseError : err);
|
||||
|
||||
if (isObject(err)) {
|
||||
Object.keys(err).forEach(key => Object.defineProperty(firebaseError, key, { value: err[key] }));
|
||||
if (errorPrefix) {
|
||||
firebaseError.code = toWebSDKErrorCode(err.code || '', errorPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
return reject(firebaseError);
|
||||
}
|
||||
return resolve(resp);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue