UNPKG

extendable-http-errors

Version:

Extendable http error for node server using es2015, covers most HTTP default errors and allow extending them for custom errors.

16 lines (12 loc) 499 B
const extendableHttpErrors = require('extendable-http-errors'); class BadLoginRequest extends extendableHttpErrors.httpErrors.BadRequestError { constructor(msg, section, code, reason){ reason = reason.toUpperCase(); super(msg, section, code, {reason: reason}); } } const customErrors = { BadLoginRequest }; extendableHttpErrors.initGlobalErrors(customErrors); console.log(new BadLoginRequest("Bad Login Request!", "SpecialLogin", 9876, "User is not special enough"));