diff --git a/lib/http-error.js b/lib/http-error.js index 8eb9f2f6c..fe410e986 100644 --- a/lib/http-error.js +++ b/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) @@ -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 } }