[functions][js] HttpError can now correctly extend Error

This commit is contained in:
Salakar
2018-09-21 00:03:00 +01:00
parent 6ea5040950
commit 6dcba98e14

View File

@@ -1,7 +1,6 @@
import type { FunctionsErrorCode } from './types.flow';
export default class HttpsError {
// TODO extends Error
export default class HttpsError extends Error {
+details: ?any;
+message: string;
@@ -9,14 +8,9 @@ export default class HttpsError {
+code: FunctionsErrorCode;
constructor(code: FunctionsErrorCode, message?: string, details?: any) {
// this.code = code;
// this.details = details;
// this.message = message;
// TODO babel 7 issue... can't extend builtin classes properly.
this._error = new Error(message);
this._error.code = code;
this._error.details = details;
this._error.constructor = HttpsError;
return this._error;
super(message);
this.code = code;
this.details = details;
this.message = message;
}
}