{"name":"egg-onerror","version":"2.3.0","keywords":["egg","egg-plugin","onerror"],"author":{"name":"dead_horse"},"_id":"egg-onerror@2.3.0","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"}],"homepage":"https://github.com/eggjs/egg-onerror#readme","bugs":{"url":"https://github.com/eggjs/egg-onerror/issues"},"dist":{"shasum":"45e8fb513de361b32d20c762221deb9692f401c1","tarball":"http://registry-npm.ywwl.com/egg-onerror/download/egg-onerror-2.3.0.tgz","fileCount":9,"integrity":"sha512-U0jn2VMWp8jxBETImwMG7Sh3fWg0CMzlWu1nhLov5pTiCr8P1fTFtCLt63Z079PBSj1UgAOk5k8CpHaYAkZJ6A==","signatures":[{"sig":"MEUCICwyUXZR4IbpBORh9qA12fKg7UYgslquSDLatG92qf7HAiEAs7P+fWY76pEzW3jwu4NMOyi81+52MfqhRT75ylb98tA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/egg-onerror@2.3.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":50271,"size":15144,"noattachment":false,"key":"/egg-onerror/-/egg-onerror-2.3.0.tgz"},"engines":{"node":">=8.0.0"},"gitHead":"d386c177107f7db6aabc427a41f5f58797571dbe","scripts":{"ci":"npm run lint && npm run cov","cov":"egg-bin cov","lint":"eslint .","test":"npm run lint -- --fix && npm run test-local","test-local":"egg-bin test"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"eggPlugin":{"name":"onerror","optionalDependencies":["jsonp"]},"repository":{"url":"git+https://github.com/eggjs/egg-onerror.git","type":"git"},"_npmVersion":"10.7.0","description":"error handler for egg","directories":{},"_nodeVersion":"18.20.4","dependencies":{"cookie":"^0.7.2","mustache":"^2.3.0","koa-onerror":"^4.0.0","stack-trace":"^0.0.10"},"_hasShrinkwrap":false,"devDependencies":{"egg":"^3.7.0","mocha":"^10.7.3","eslint":"^8.29.0","egg-bin":"^5.5.0","egg-mock":"^5.3.0","eslint-config-egg":"^12.1.0"},"_npmOperationalInternal":{"tmp":"tmp/egg-onerror_2.3.0_1728799859425_0.663594399129485","host":"s3://npm-registry-packages"},"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\nnpm 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 accept `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 function\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\n## Contributors\n\n[![Contributors](https://contrib.rocks/image?repo=eggjs/egg-onerror)](https://github.com/eggjs/egg-onerror/graphs/contributors)\n\nMade with [contributors-img](https://contrib.rocks).\n","publish_time":1728799859681,"_cnpm_publish_time":1728799859681,"dist-tags":{"latest":"2.4.0","release-2.x":"2.4.0"}}