UNPKG

typenexus

Version:

TypeNexus is a good tool for API encapsulation and management. It provides a clean and lightweight way to package TypeORM functionality, helping you build applications faster while reducing template code redundancy and type conversion work.

24 lines (23 loc) 731 B
/** * Used to throw HTTP errors. * Just do throw new HttpError(code, message) in your controller action and * default error handler will catch it and give in your response given code and message . */ export class HttpError extends Error { httpCode; constructor(httpCode, message) { super(); Object.setPrototypeOf(this, HttpError.prototype); // Disable stack trace information Error.captureStackTrace(this, this.constructor); if (httpCode) this.httpCode = httpCode; if (message) this.message = message; // this.stack = new Error().stack; } // define a `stack` accessor and return null get stack() { return null; } }