class ApiError extends Error { statusCode: number; isOperational: boolean; constructor(statusCode: number, message: string, isOperational = true) { super(message); this.statusCode = statusCode; this.isOperational = isOperational; Error.captureStackTrace(this, this.constructor); } static badRequest(message = 'Bad Request'): ApiError { return new ApiError(400, message); } static unauthorized(message = 'Unauthorized'): ApiError { return new ApiError(401, message); } static forbidden(message = 'Forbidden'): ApiError { return new ApiError(403, message); } static notFound(message = 'Not Found'): ApiError { return new ApiError(404, message); } static conflict(message = 'Conflict'): ApiError { return new ApiError(409, message); } static internal(message = 'Internal Server Error'): ApiError { return new ApiError(500, message, false); } } export default ApiError;