{"id":24658023,"url":"https://github.com/eggjs/onerror","last_synced_at":"2025-10-28T15:58:27.551Z","repository":{"id":9860686,"uuid":"63207579","full_name":"eggjs/onerror","owner":"eggjs","description":"error handler for egg","archived":false,"fork":false,"pushed_at":"2025-02-02T15:54:31.000Z","size":117,"stargazers_count":57,"open_issues_count":2,"forks_count":14,"subscribers_count":5,"default_branch":"2.x","last_synced_at":"2025-10-19T07:35:44.538Z","etag":null,"topics":["egg-plugin"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eggjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-07-13T02:28:43.000Z","updated_at":"2025-02-02T15:51:40.000Z","dependencies_parsed_at":"2025-04-19T18:24:46.865Z","dependency_job_id":"fadde63a-9cfe-4ab7-934e-a88d78051b45","html_url":"https://github.com/eggjs/onerror","commit_stats":{"total_commits":62,"total_committers":16,"mean_commits":3.875,"dds":0.6935483870967742,"last_synced_commit":"953716dcbfaae0c6098cbbce5758f3db197a1599"},"previous_names":["eggjs/onerror"],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/eggjs/onerror","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fonerror","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fonerror/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fonerror/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fonerror/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eggjs","download_url":"https://codeload.github.com/eggjs/onerror/tar.gz/refs/heads/2.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fonerror/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281467278,"owners_count":26506462,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-28T02:00:06.022Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["egg-plugin"],"created_at":"2025-01-26T01:01:17.832Z","updated_at":"2025-10-28T15:58:27.547Z","avatar_url":"https://github.com/eggjs.png","language":"HTML","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@2\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) =\u003e 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 \u0026 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","funding_links":[],"categories":["HTML"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feggjs%2Fonerror","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feggjs%2Fonerror","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feggjs%2Fonerror/lists"}