UNPKG

@metamask/kernel-errors

Version:
26 lines 899 B
import { ErrorCode } from "./constants.mjs"; export class BaseError extends Error { constructor(code, message, options = {}) { const { data, cause, stack } = options; super(message, { cause }); this.name = this.constructor.name; this.code = code; this.data = data; // override the stack property if provided if (stack) { this.stack = stack; } harden(this); } /** * A placeholder for unmarshal functionality. Should be implemented in subclasses. * * @param _marshaledError - The marshaled error to unmarshal. * @param _unmarshalErrorOptions - A function to unmarshal the error options. */ static unmarshal(_marshaledError, _unmarshalErrorOptions) { throw new Error('Unmarshal method not implemented'); } } harden(BaseError); //# sourceMappingURL=BaseError.mjs.map