UNPKG

verror-0

Version:

VError without dependencies on top of nodejs standart library

58 lines (57 loc) 1.97 kB
import { Options } from './types.js'; import { findCause, hasCause } from './cause.js'; export declare class VError extends Error { message: string; protected jse_shortmsg: string; protected jse_cause: Error; protected jse_info: Record<string, unknown>; constructor(options: Options | Error, message: string, ...params: unknown[]); constructor(message?: string, ...params: unknown[]); toString(): string; /** * Link to {@link cause}. For compatibility with original verror. */ static cause: (err: unknown) => Error | null; /** * Link to {@link info}. For compatibility with original verror. */ static info: (err: unknown) => import("./types.js").Info; /** * Finds cause in stack by error name. * Link to {@link findCause}. For compatibility with original verror. * * @example * // Single string * VError.findCauseByName(err, 'PayloadTooLargeException'); * * @example * // Array of names * VError.findCauseByName(err, ['PayloadTooLargeException', 'OtherError']); * * @example * // Set of names * VError.findCauseByName(err, new Set(['PayloadTooLargeException', 'OtherError'])); */ static findCauseByName: typeof findCause; /** * Check if cause exists in stack by error name. * Link to {@link hasCause}. For compatibility with original verror. * * @example * // Single string * VError.hasCauseWithName(err, 'PayloadTooLargeException'); * * @example * // Array of names * VError.hasCauseWithName(err, ['PayloadTooLargeException', 'OtherError']); * * @example * // Set of names * VError.hasCauseWithName(err, new Set(['PayloadTooLargeException', 'OtherError'])); */ static hasCauseWithName: typeof hasCause; /** * Link to {@link stack}. For compatibility with original verror. */ static fullStack: (err: unknown) => string; }