AppException
AppException is a small and easy-to-use HTTP error library for Node. It's an addition to HttpException
Features
AppException improves HttpException work making easier to create errors with custom application codes.
How to Use
; // via the AppException class. Parameters: message, application error code, http error codeconst errorOne = 'error message' 9 500; // via the createError factoryconst errorTwo = AppException; // via AppException's static HTTP status-specific methodsthrow AppException;throw AppException;
Integration with Express.js
const app = ; // other stuff // after all your app.useapp;
Catching any exception and returning as response with Express.js
const app = ; // first app.useapp;
Syntax
AppException[httpStatusType]([message], [code])
AppException.internalServerError([message], [code])
AppException.badRequest([message], [code])
message
{ String } error messagecode
{ String / Integer } application error code
Returns a new AppException object.
const error = AppException throw error
new AppException([message], [code], [status])
message
{ String } error messagecode
{ String / Integer } application error codestatus
{ Integer } http error code
Returns a new AppException object.
throw 'error' 9 400
AppException.createError([options])
options
{ Object }
Return a new AppException object.
const error = AppException throw error
Contact
For support and questions contact mail me at team@99xp.org