webappengine
Version:
A web application platform that can host multiple web apps running with Node.js.
32 lines (28 loc) • 535 B
JavaScript
/**
* err_client
*
* Examples:
*
* app.use(middleware.err_client({ error: 'XHR error' }))
*
* Options:
*
* - error error message
*
* @param {Object} options
* @return {Function}
* @api public
*/
module.exports = function err_client(options) {
options = options || {};
var error = options.error || '';
return function(err, req, res, next) {
if (req.xhr) {
res.send(500, {
error: error
});
} else {
next(err);
}
};
};