diff --git a/index.js b/index.js index 82271f6..e6f9aba 100644 --- a/index.js +++ b/index.js @@ -70,7 +70,7 @@ function createError () { } if (typeof status === 'number' && (status < 400 || status >= 600)) { - deprecate('non-error status code; use only 4xx or 5xx status codes') + deprecate('non-error status code ' + status + '; use only 4xx or 5xx status codes') } if (typeof status !== 'number' || diff --git a/test/test.js b/test/test.js index 7db9f16..d5822db 100644 --- a/test/test.js +++ b/test/test.js @@ -453,3 +453,17 @@ describe('HTTP Errors', function () { assert(Error.isError(new createError['500']())) }) }) + +describe('Deprecation notice', function () { + it('createError() deprecated', function (done) { + process.on('deprecation', (warning) => { + assert.strictEqual(warning.name, 'DeprecationError') + assert.strictEqual(warning.message, 'non-error status code 999; use only 4xx or 5xx status codes') + done() + }) + + createError(999, { + id: 1 + }) + }) +})