UNPKG

@creamapi/cream

Version:

Concise REST API Maker - An extension library for express to create REST APIs faster

37 lines (36 loc) 941 B
import { Response, Request } from 'express'; /** * This error is used to communicate with the user that made the api rest call. * It allows to set the status code of the transaction. */ export declare class RestError extends Error { readonly statusCode: number; /** * @param message The error message * @param statusCode the http status code of the transaction */ constructor(message: string, statusCode: number); } /** * This interface is populated with the thrown error and the correct http status code */ export interface ErrorInfo { /** * The generated error */ err: Error; /** * The http status code */ status: number; } /** * This interface is used to handle runtime exceptions */ export interface ExpressErrorHandler { /** * This method is called whenever an exception is thrown * */ handle(err: Error, req: Request, res: Response): void; }