import BaseError, { WError } from 'verror'; export declare type Link = string | { href: string; meta?: Meta; }; export interface Source { pointer?: string; parameter?: string; } export interface Meta { [key: string]: any; } export interface ErrorOptions extends BaseError.Options { id?: BotchedError['id']; code?: BotchedError['code']; title?: BotchedError['title']; source?: BotchedError['source']; links?: BotchedError['links']; meta?: BotchedError['meta']; statusCode?: BotchedError['statusCode']; headers?: BotchedError['headers']; } export default class BotchedError extends WError { static readonly version: string; /** * Default values for class instances */ static id: BotchedError['id']; static code: BotchedError['code']; static title: BotchedError['title']; static source: BotchedError['source']; static links: BotchedError['links']; static meta: BotchedError['meta']; static statusCode: BotchedError['statusCode']; static headers: BotchedError['headers']; /** * Parse options from VError args * * @param {any[]} args * @returns {object} */ static getOptionsFromArgs(args: any[]): any; /** * Unique identifier for this error instance * Useful for correlating errors in logs * * Do not put any sensitive information here! */ id: string; /** * Application specific error codes * * Do not put any sensitive information here! */ code: string; /** * A short human-readable title for this type of error * * Do not put any sensitive information here! */ title: string; /** * An object explaining the source of the error to the user - useful for validation errors * * Do not put any sensitive information here! */ source: Source; /** * An object with links to some documentation where a user might get more information about this error * * Do not put any sensitive information here! */ links: { about: Link; }; /** * An object with any other non-standard information about the error * * Do not put any sensitive information here! */ meta: object; /** * Convenience bool to check for this type of error */ readonly isBotched: boolean; /** * Error details (from Error message) */ readonly detail: string | undefined; /** * HTTP Status code for this type of error * * Do not put any sensitive information here! */ statusCode: number; /** * HTTP Headers to send * * Do not put any sensitive information here! */ headers: { [key: string]: string; }; /** * HTTP Status code in string format */ readonly status: string; /** * Botched error version */ readonly version: string; /** * Is this a server error? */ readonly isServer: boolean; /** * Thin layer on top of "verror" * @see https://github.com/joyent/node-verror */ constructor(message?: string, ...params: any[]); constructor(options?: ErrorOptions | Error, message?: string, ...params: any[]); /** * Create a JSON friendly representation of this error * Defaults to the JSON:API spec * * @return {object} */ toJSON(): object; }