Skip to content

Commit

Permalink
Merge pull request #56 from strongloop/fix-unknown-package-name-response
Browse files Browse the repository at this point in the history
Make 404 responses compatible with CouchDB API
  • Loading branch information
rlidwka committed Mar 13, 2014
2 parents f839837 + dabf5e1 commit 0afd9d1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,15 @@ module.exports = function(config_hash) {
if (err.status && err.status >= 400 && err.status < 600) {
if (calls == 1) {
res.status(err.status)
res.send({error: err.msg || err.message || 'unknown error'})
var body = {error: err.msg || err.message || 'unknown error'};

// Make 404 responses compliant with CouchDB REST API
if (err.status == 404) {
body.reason = body.error
body.error = 'not_found'
}

res.send(body)
}
} else {
Logger.logger.error({err: err}, 'unexpected error: @{!err.message}\n@{err.stack}')
Expand Down

0 comments on commit 0afd9d1

Please sign in to comment.