@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
23 lines • 637 B
JavaScript
export const ERROR_HARMLESS = 100;
export const ERROR_FATAL = 500;
export function ErrorHandler(error) {
let {
message
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
message: null
};
let code = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ERROR_HARMLESS;
let thisError = this && this.err;
if (typeof error === 'object') {
message = error.message;
}
if (thisError) {
thisError = new Error(`${error}\n\n${message}`);
}
if (code === ERROR_FATAL) {
throw thisError;
} else {
console.log(thisError);
}
}
//# sourceMappingURL=error-helper.js.map