UNPKG

http-errors-plus

Version:

Next-gen HTTP error handling for modern JavaScript and TypeScript apps — structured, overrideable, and developer-focused.

37 lines (36 loc) 1.01 kB
/** * @typedef {Object} SerializedHttpError * @property {number} status * @property {string} code * @property {string} message * @property {string} [detail] * @property {string} [path] * @property {string} [method] * @property {string} [timestamp] * @property {string} [requestId] * @property {string} [traceId] */ export class HttpError extends Error { /** * @param {number} status * @param {Omit<SerializedHttpError, 'status'>} options */ constructor(status: number, options: Omit<SerializedHttpError, "status">); /** @type {SerializedHttpError} */ meta: SerializedHttpError; /** * @returns {SerializedHttpError} */ toJSON(): SerializedHttpError; } export type SerializedHttpError = { status: number; code: string; message: string; detail?: string | undefined; path?: string | undefined; method?: string | undefined; timestamp?: string | undefined; requestId?: string | undefined; traceId?: string | undefined; };