UNPKG

@ozmap/logger

Version:
31 lines (30 loc) 845 B
/// <reference types="node" /> import { ServerResponse } from 'http'; /** * Http error class. */ export declare class HttpError extends Error { /** * Stores the HTTP response message. */ message: string; /** * Stores the HTTP response status code. */ code: number; /** * HttpError class constructor. * * @param message The response message. * @param code The response status code. */ constructor(message: string, code: number); /** * Method for responding HTTP request with standard error. * * @param res The server response instance. * @param isJson If the response content is JSON. * @returns The server response. */ respond<RES extends ServerResponse = ServerResponse>(res: ServerResponse, isJson: boolean): RES; }