UNPKG

@360works/fmpromise

Version:
19 lines (16 loc) 451 B
/** * Custom error type for scripting engine error results. */ class FMPromiseError extends Error { private readonly code: number | undefined; constructor(obj: { message?: string, code?: number }) { super(); Object.assign(this, obj); this.message = obj.message || 'Unknown error'; this.code = obj.code; this.name = this.constructor.name; } toString(): string { return this.message + (this.code ? ' (' + this.code + ')' : ''); } }