Default error handling plugin for egg.
$ npm i egg-onerror
egg-onerror
is on by default in egg. But you still can configure its properties to fits your scenarios.
errorPageUrl: String
- If user request html pages in production environment and unexpected error happened, it will redirect user toerrorPageUrl
.accepts: Function
- detect user's request accpetjson
orhtml
.
// an accept detect function that mark all request with `x-request-with=XMLHttpRequest` header accepts json.
function accpets(ctx) {
if (ctx.get('x-request-with') === 'XMLHttpRequest') return 'json';
return 'html';
}
Please open an issue here.