mongodb-js-errors
v0.5.0
Published
Helpers for handling errors from the MongoDB driver.
Downloads
226
Maintainers
Keywords
Readme
mongodb-errors
Helpers for handling errors from the MongoDB driver.
Example
var express = require('express');
var app = module.exports = express();
app.use(require('mongodb-js-errors/express'));
app.use(function(err, req, res) {
var payload = err.output.payload;
res.format({
text: function() {
res.status(err.output.statusCode).send(payload.message);
},
json: function() {
res.status(err.output.statusCode).send(payload);
}
});
});
License
Apache 2.0