UNPKG

windows-ss

Version:

[![npm version](https://badge.fury.io/js/windows-ss.svg)](https://badge.fury.io/js/windows-ss)

36 lines (29 loc) 800 B
export class ClientError extends Error { constructor(message = 'No message provided, an error with errors?') { super(message); this.name = this.constructor.name; // eslint is drunk // eslint-disable-next-line (Error as any).captureStackTrace?.(this, this.constructor); } public static from<T = ClientError>(obj: PlainErrorObject | Error): T { const clientError = new this(); clientError.name = obj.name; clientError.message = obj.message; clientError.stack = obj.stack; // @ts-expect-error return clientError; } public toPlainObject(): PlainErrorObject { return { name: this.name, message: this.message, stack: this.stack, }; } } export interface PlainErrorObject { name: string; message: string; stack?: string; }