Created
January 20, 2020 12:12
-
-
Save kasvith/ebd321e2db275edb2a8dc69d4f2b77a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const httpStatus = require('http-status') | |
const errorCodes = require('./errorCodes') | |
module.exports = function APIError ( | |
message, | |
status = httpStatus.INTERNAL_SERVER_ERROR, | |
errorCode = errorCodes.UnkownError, | |
errors = null | |
) { | |
Error.captureStackTrace(this, this.constructor) | |
this.name = this.constructor.name | |
this.message = message | |
this.status = status | |
this.errorCode = errorCode | |
this.errors = errors | |
} | |
require('util').inherits(module.exports, Error) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment