error-express
Version:
Are you tired of messy error handling in your Express apps? Say goodbye to confusion and frustration with **`error-express`**, a powerful NPM package designed to streamline error management in your Express applications.
27 lines (24 loc) • 803 B
TypeScript
import { Request, Response, NextFunction } from 'express';
interface IErrorResponse {
message: string;
statusCode: number;
status: string;
serializeErrors(): IError;
}
interface IError {
message: string;
statusCode: number;
status: string;
}
declare abstract class CustomError extends Error {
abstract status: string;
private readonly statusCode;
protected constructor(message: string, statusCode: number);
serializeErrors(): IError;
}
declare class ServerError extends CustomError {
status: string;
constructor(message: string, statusCode?: number);
}
declare const globalErrorHandler: (err: any, _req: Request, res: Response, _next: NextFunction) => void;
export { CustomError, type IError, type IErrorResponse, ServerError, globalErrorHandler };