Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
unreleased
==================

* fix: use the status code as the error body when it has no name
* deps:
* debug@^4.4.3
* statuses@^2.0.2
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function getErrorMessage (err, status, env) {
}
}

return msg || statuses.message[status]
return msg || statuses.message[status] || String(status)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"eslint-plugin-standard": "^4.1.0",
"mocha": "^11.0.1",
"nyc": "^17.1.0",
"supertest": "^7.0.0"
"supertest": "7.3.0"
},
"files": [
"index.js"
Expand Down
11 changes: 11 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,17 @@ var topDescribe = function (type, createServer) {
.expect(501, /<pre>Not Implemented<\/pre>/, done)
})

it('should send status code when production and no status code name', function (done) {
var err = createError('boom!', {
status: 499
})
wrapper(request(createServer(err, {
env: 'production'
}))
.get('/foo'))
.expect(499, /<pre>499<\/pre>/, done)
})

describe('when there is a request body', function () {
it('should not hang/error when unread', function (done) {
var buf = Buffer.alloc(1024 * 16, '.')
Expand Down
Loading