haraka-plugin-webmailer/errorSender.js

14 lines
315 B
JavaScript

module.exports = function(req, res, next) {
res.sendError = function(code, text) {
try {
res.status(code).type('json').send(JSON.stringify({
error: text
}));
} catch(err) {
console.error("Error formatting error response: ", err);
res.sendStatus(500);
}
}
next();
}