UNPKG

base-error

Version:

Class extended from javascript Error with support for stack trace

23 lines (18 loc) 449 B
export default class BaseError extends Error { constructor(message) { super(message); this.message = this.message || message; if (!this.stack) { this.captureStackTrace(); } } captureStackTrace() { if (Error.captureStackTrace) { Error.captureStackTrace(this); } else { const err = new Error(); this.stack = err.stack; } } } BaseError.prototype.name = 'BaseError';