export interface BackendErrorParams { readonly cause: string; readonly message: string; readonly status: number; readonly stack?: string; } export class BackendError { readonly cause: string; readonly message: string; readonly stack?: string readonly status: number constructor( { cause, message, stack, status }: BackendErrorParams ) { this.cause = cause; this.message = message; this.stack = stack; this.status = status; } toJSON() { return { cause: this.cause, message: this.message, stack: this.stack, status: this.status } } }