UNPKG

webappengine

Version:

A web application server that can host multiple web apps running with Node.js.

36 lines (30 loc) 574 B
'use strict'; /** * errclient * * Examples: * * app.use(middleware.errclient({ error: 'XHR error' })) * * Options: * * - error error message * * @param {Object} options * @return {Function} * @api public */ var errclient = function errclient(options) { options = options || {}; var error = options.error || ''; return function (err, req, res, next) { if (req.xhr) { res.send(500, { error: error }); return; } next(err); }; }; module.exports = errclient;