package
error handler for egg
npm install egg-onerrorGitHub-flavored package documentation.
Across all versions, last 30 days.
99,173 in 30 days
Runtime metadata.
Tagged topics.
Default error handling plugin for egg.
npm i egg-onerroregg-onerror is on by default in egg. But you still can configure its properties to fits your scenarios.
errorPageUrl: String or Function - If user request html pages in production environment and unexpected error happened, it will redirect user to errorPageUrl.accepts: Function - detect user's request accept json or html.all: Function - customize error handler, if all present, negotiation will be ignored.html: Function - customize html error handler.text: Function - customize text error handler.json: Function - customize json error handler.jsonp: Function - customize jsonp error handler.// config.default.js
// errorPageUrl support function
exports.onerror = {
errorPageUrl: (err, ctx) => ctx.errorPageUrl || '/500',
};
// an accept detect function that mark all request with `x-requested-with=XMLHttpRequest` header accepts json.
function accepts(ctx) {
if (ctx.get('x-requested-with') === 'XMLHttpRequest') return 'json';
return 'html';
}Please open an issue here.
Made with contributors-img.
dead_horse
dead_horse@qq.com
Estimated unpacked size across 7 packages.
283.7 kB
Includes dependencies.
4 direct · 4 outdated
^0.7.2
2.0.2
^2.3.0
4.2.0
^4.0.0
5.0.1
^0.0.10
1.0.0