diff --git a/lib/index.js b/lib/index.js index ec25fe62..19eb81c1 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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}')