{"name":"egg-onerror","version":"2.2.0","description":"error handler for egg","eggPlugin":{"name":"onerror","optionalDependencies":["jsonp"]},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-onerror.git"},"keywords":["egg","egg-plugin","onerror"],"dependencies":{"cookie":"^0.3.1","koa-onerror":"^4.0.0","mustache":"^2.3.0","stack-trace":"^0.0.10"},"devDependencies":{"egg":"^3.7.0","egg-bin":"^5.5.0","egg-ci":"^2.2.0","egg-mock":"^5.3.0","eslint":"^8.29.0","eslint-config-egg":"^12.1.0"},"engines":{"node":">=8.0.0"},"scripts":{"test":"npm run lint -- --fix && npm run test-local","test-local":"egg-bin test --full-trace","cov":"egg-bin cov --full-trace","lint":"eslint .","ci":"npm run lint && npm run cov"},"ci":{"version":"14, 16, 18"},"author":{"name":"dead_horse"},"gitHead":"05f25f2770d2c4ced5d4cb95674318e27eead9e8","bugs":{"url":"https://github.com/eggjs/egg-onerror/issues"},"homepage":"https://github.com/eggjs/egg-onerror#readme","_id":"egg-onerror@2.2.0","_nodeVersion":"18.12.1","_npmVersion":"6.14.17","dist":{"integrity":"sha512-wYAU2hBASXWaFD2A2WiUbffpEaLUiWeYkHN0u3Fvbi2uYeMSmQoqaIUsBbKb6paopiwRFFQzm8M0T3GVLwU1jw==","shasum":"6a1c2d61cc3936d5a1a633cba09098dffa59557a","tarball":"http://registry-npm.ywwl.com/egg-onerror/download/egg-onerror-2.2.0.tgz","fileCount":10,"unpackedSize":53695,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEbgBc/1Xj9xwhnOlitNJiVvVZPCAy79WcLZw3YO2l6ZAiEA+fqfBEwIlSr+Ss/7mKQtfeaRgZSMaVhxMuKwbsf+yao="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjlbi+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqwhw/6AtbOyjx2rxEqdzTJ0OiMfoScz847w6EnEv2Fd+78NkcPinAT\r\nj7xXOakUKDXEcja+TRoJXZTt2TKGH7s6YNv2a/VSr1dHQRw78L1BrDxJ/C5Z\r\n+ZcOXCPhSJc/Qrd4M0Gx1c87o5thTkTW4ig1oMmdPLgbB2blMIfDxO8TsvKh\r\naayjaJ0yE5un1P83HanSFXO3K2nfYQKngMC2y9HAW5KZ6JwmyKRQU+JBqMwq\r\nQkCE2lqsZboVyKo4JA37e+EqKtNco4JXzzlTJbkQ2oDGHkd/3cnyFQc2EiE9\r\nge2glTLlP6eZLqoxUBW4yB6ZZ/+RMqJ1RumOkavZSdZUivNtY/tozEmrLHEz\r\nRhabQJKLJ8MEkrL+Inspd2+DGcrCio31HrNW0PRl5xuy+CbJv94StdXzqklV\r\n1xMd/aA8PKdaBrkLZGY8XyV1nVyOuOmdqq6e4XtWSwlJrFAkWeWj6LnhUaRz\r\nhX/jVPJRAt7YczRWkKh6yLGStOsoBhpiq8+GyJNBiBcvELokLXIXwKtBV4B8\r\nb0/0x0ISubD9ZClzk8V1oxLpexHFOCsW89zo4+gzQm4pj2cGrhUh5TmSlniv\r\nOcTUWuse2P1owr7pr3PtvLgrVf0oHqKsLoXuvBt3gfw4XRpKMsuCqKCcF+eE\r\ngYobRbPDfVCxS1MVl4BSIdDNwwU9esiblDg=\r\n=fLM0\r\n-----END PGP SIGNATURE-----\r\n","size":16392,"noattachment":false,"key":"/egg-onerror/-/egg-onerror-2.2.0.tgz"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"directories":{},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"wanghx","email":"whxaxes@gmail.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":"sakura9515@gmail.com"},{"name":"eggjs-admin","email":"fengmk2+eggjs@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/egg-onerror_2.2.0_1670756542004_0.8513260741639048"},"_hasShrinkwrap":false,"readme":"# egg-onerror\n\n[![NPM version][npm-image]][npm-url]\n[![Node.js CI](https://github.com/eggjs/egg-onerror/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/egg-onerror/actions/workflows/nodejs.yml)\n[![Test coverage][codecov-image]][codecov-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/egg-onerror.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/egg-onerror\n[codecov-image]: https://codecov.io/github/eggjs/egg-onerror/coverage.svg?branch=master\n[codecov-url]: https://codecov.io/github/eggjs/egg-onerror?branch=master\n[snyk-image]: https://snyk.io/test/npm/egg-onerror/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/egg-onerror\n[download-image]: https://img.shields.io/npm/dm/egg-onerror.svg?style=flat-square\n[download-url]: https://npmjs.org/package/egg-onerror\n\nDefault error handling plugin for egg.\n\n## Install\n\n```bash\n$ npm i egg-onerror\n```\n\n## Usage\n\n`egg-onerror` is on by default in egg. But you still can configure its properties to fits your scenarios.\n\n- `errorPageUrl: String or Function` - If user request html pages in production environment and unexpected error happened, it will redirect user to `errorPageUrl`.\n- `accepts: Function` - detect user's request accpet `json` or `html`.\n- `all: Function` - customize error handler, if `all` present, negotiation will be ignored.\n- `html: Function` - customize html error handler.\n- `text: Function` - customize text error handler.\n- `json: Function` - customize json error handler.\n- `jsonp: Function` - customize jsonp error handler.\n\n```js\n// config.default.js\n// errorPageUrl support funtion\nexports.onerror = {\n  errorPageUrl: (err, ctx) => ctx.errorPageUrl || '/500',\n};\n\n// an accept detect function that mark all request with `x-requested-with=XMLHttpRequest` header accepts json.\nfunction accepts(ctx) {\n  if (ctx.get('x-requested-with') === 'XMLHttpRequest') return 'json';\n  return 'html';\n}\n```\n\n## Questions & Suggestions\n\nPlease open an issue [here](https://github.com/eggjs/egg/issues).\n\n## License\n\n[MIT](https://github.com/eggjs/egg-onerror/blob/master/LICENSE)\n","publish_time":1670756542241,"_cnpm_publish_time":1670756542241,"dist-tags":{"latest":"2.4.0","release-2.x":"2.4.0"}}