mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-01-12 22:50:20 +08:00
[common] NativeError class implementation
This commit is contained in:
14
src/common/NativeError.js
Normal file
14
src/common/NativeError.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import type {
|
||||
NativeErrorObject,
|
||||
NativeErrorInterface,
|
||||
} from './commonTypes.flow';
|
||||
|
||||
export default class NativeError extends Error implements NativeErrorInterface {
|
||||
constructor(nativeError: NativeErrorObject) {
|
||||
super(nativeError.message);
|
||||
this.code = nativeError.code;
|
||||
this.message = nativeError.message;
|
||||
this.nativeErrorCode = nativeError.nativeErrorCode;
|
||||
this.nativeErrorMessage = nativeError.nativeErrorMessage;
|
||||
}
|
||||
}
|
||||
19
src/common/commonTypes.flow.js
Normal file
19
src/common/commonTypes.flow.js
Normal file
@@ -0,0 +1,19 @@
|
||||
export type NativeErrorObject = {
|
||||
code: string,
|
||||
message: string,
|
||||
nativeErrorCode: string | number,
|
||||
nativeErrorMessage: string,
|
||||
};
|
||||
|
||||
export type NativeErrorResponse = {
|
||||
error: NativeErrorObject,
|
||||
// everything else
|
||||
[key: string]: ?any,
|
||||
};
|
||||
|
||||
export interface NativeErrorInterface extends Error {
|
||||
+code: string;
|
||||
+message: string;
|
||||
+nativeErrorCode: string | number;
|
||||
+nativeErrorMessage: string;
|
||||
}
|
||||
Reference in New Issue
Block a user