UNPKG

expresss-ts

Version:

CLI to create an Express TypeScript starter project

30 lines (26 loc) 558 B
class ApiError extends Error { statusCode: number; data: null | any; message: string; success: boolean; errors: any[]; constructor( statusCode: number, message = "Something went wrong", errors: any[] = [], stack = "" ) { super(message); this.statusCode = statusCode; this.data = null; this.message = message; this.success = false; this.errors = errors; if (stack) { this.stack = stack; } else { Error.captureStackTrace(this, this.constructor); } } } export default ApiError;