UNPKG

@chubbyts/chubbyts-throwable-to-error

Version:
16 lines (15 loc) 532 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.throwableToError = void 0; const throwableToError = (e) => { if (e instanceof Error) { return e; } const error = new Error(typeof e === 'object' ? `${JSON.stringify(e)}` : `${String(e)}`); // eslint-disable-next-line functional/immutable-data error.name = typeof e; // eslint-disable-next-line functional/immutable-data error.stack = undefined; return error; }; exports.throwableToError = throwableToError;