Skip to content

Instantly share code, notes, and snippets.

@kasvith
Created January 20, 2020 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasvith/ebd321e2db275edb2a8dc69d4f2b77a2 to your computer and use it in GitHub Desktop.
Save kasvith/ebd321e2db275edb2a8dc69d4f2b77a2 to your computer and use it in GitHub Desktop.
'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