Skip to content

Commit

Permalink
feat: error.status (deprecate error.code)
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Nov 10, 2018
1 parent 549712a commit 5ac4225
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/http-error.js
@@ -1,5 +1,5 @@
module.exports = class HttpError extends Error {
constructor (message, code, headers) {
constructor (message, statusCode, headers) {
super(message)

// Maintains proper stack trace (only available on V8)
Expand All @@ -9,7 +9,13 @@ module.exports = class HttpError extends Error {
}

this.name = 'HttpError'
this.code = code
this.status = statusCode
Object.defineProperty(this, 'code', {
get () {
console.warn('`error.code` is deprecated, use `error.status`.')
return statusCode
}
})
this.headers = headers
}
}

0 comments on commit 5ac4225

Please sign in to comment.