{"name":"egg-onerror","version":"0.0.1","description":"egg plugin <egg-onerror>","keywords":["egg","eggjs","egg-plugin"],"homepage":"https://github.com/eggjs/egg-onerror","license":"MIT","author":{"name":"eggjs"},"contributors":[{"name":"TZ","email":"atian25@qq.com"},{"name":"popomore","email":"sakura9515@gmail.com"},{"name":"fengmk2","email":"m@fengmk2.com"},{"name":"dead-horse","email":"heyiyu.deadhorse@gmail.com"}],"repository":{"type":"git","url":"git+ssh://git@github.com/eggjs/egg-onerror.git"},"bugs":{"url":"https://github.com/eggjs/egg-onerror/issues"},"_id":"egg-onerror@0.0.1","scripts":{},"_shasum":"f388c7772ad0a939e78ea388c248172248744b80","_from":".","_npmVersion":"2.15.1","_nodeVersion":"4.4.4","_npmUser":{"name":"atian25","email":"atian25@qq.com"},"dist":{"shasum":"f388c7772ad0a939e78ea388c248172248744b80","tarball":"http://registry-npm.ywwl.com/egg-onerror/download/egg-onerror-0.0.1.tgz","integrity":"sha512-/6CCKxEHi6mKX0sTfIJopVLIBSpKxwBt6yoPaNiiv5qh685D/td2Lt7sLBK2EZFrXbTGvp4xQRjlDSQTIw6DPA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDsqCe96nxGmMgP1z7RWpAc8TQjIuwt4wlljNpu74hFMQIhAOePuSTqnpwa8tXRhIJU3vGILYA8Jvel1F6Jt22yXvPB"}],"size":422,"noattachment":false,"key":"/egg-onerror/-/egg-onerror-0.0.1.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/egg-onerror-0.0.1.tgz_1464253738764_0.9529396379366517"},"directories":{},"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":1464253741426,"_cnpm_publish_time":1464253741426,"dist-tags":{"latest":"2.4.0","release-2.x":"2.4.0"}}