{"id":17499465,"url":"https://github.com/simonepri/restify-errors-options","last_synced_at":"2025-03-29T17:22:18.651Z","repository":{"id":66099004,"uuid":"98793274","full_name":"simonepri/restify-errors-options","owner":"simonepri","description":"🔧 Add custom options to Restify's errors","archived":false,"fork":false,"pushed_at":"2018-02-22T20:11:16.000Z","size":32,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-21T16:07:01.533Z","etag":null,"topics":["restify","restify-errors","restify-errors-options"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/simonepri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2017-07-30T11:33:44.000Z","updated_at":"2022-05-18T06:10:24.000Z","dependencies_parsed_at":"2023-03-10T23:37:01.673Z","dependency_job_id":null,"html_url":"https://github.com/simonepri/restify-errors-options","commit_stats":{"total_commits":60,"total_committers":2,"mean_commits":30.0,"dds":0.25,"last_synced_commit":"f8412de9ba67ece3a1632f3935bea1c778666b9e"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonepri%2Frestify-errors-options","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonepri%2Frestify-errors-options/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonepri%2Frestify-errors-options/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonepri%2Frestify-errors-options/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonepri","download_url":"https://codeload.github.com/simonepri/restify-errors-options/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246216537,"owners_count":20742004,"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","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":["restify","restify-errors","restify-errors-options"],"created_at":"2024-10-19T17:09:12.977Z","updated_at":"2025-03-29T17:22:18.612Z","avatar_url":"https://github.com/simonepri.png","language":"JavaScript","readme":"# restify-errors-options\n[![Travis CI](https://travis-ci.org/simonepri/restify-errors-options.svg?branch=master)](https://travis-ci.org/simonepri/restify-errors-options) [![Codecov](https://img.shields.io/codecov/c/github/simonepri/restify-errors-options/master.svg)](https://codecov.io/gh/simonepri/restify-errors-options) [![npm](https://img.shields.io/npm/dm/restify-errors-options.svg)](https://www.npmjs.com/package/restify-errors-options) [![npm version](https://img.shields.io/npm/v/restify-errors-options.svg)](https://www.npmjs.com/package/restify-errors-options) [![npm dependencies](https://david-dm.org/simonepri/restify-errors-options.svg)](https://david-dm.org/simonepri/restify-errors-options) [![npm dev dependencies](https://david-dm.org/simonepri/restify-errors-options/dev-status.svg)](https://david-dm.org/simonepri/restify-errors-options#info=devDependencies)\n\u003e 🔧 Add custom options to Restify's errors!\n\n\u003chr\u003e\n\u003cp align=\"center\"\u003e\u003cstrong\u003eDEPRECATED!!!\u003c/strong\u003e\u003c/p\u003e\n\u003chr\u003e\n\n## Install\n\n```\n$ npm install --save restify-errors-options\n```\n\n## Usage\n```js\nconst errorsOptions = require('restify-errors-options');\n// Is extremely important to require restify-errors-options before restify.\nconst errors = require('restify-errors');\n\n// Default behaviour\nconst err1 = new errors.NotFoundError({errno: 'NFE'});\nconsole.log(err1.toJSON());\n//=\u003e {code: 'NotFound', message: ''}\n\n// Add errno as option to add to the body\nerrorsOptions.add('errno');\nconst err2 = new errors.NotFoundError({errno: 'NFE'});\nconsole.log(err2.toJSON());\n//=\u003e {code: 'NotFound', message: '', errno: 'NFE'}\nconsole.log(err1.toJSON());\n//=\u003e {code: 'NotFound', message: ''}\n\n// Restore the default behaviour\nerrorsOptions.delete('errno');\nconst err3 = new errors.NotFoundError({errno: 'NFE'});\nconsole.log(err3.toJSON());\n//=\u003e {code: 'NotFound', message: ''}\nconsole.log(err2.toJSON());\n//=\u003e {code: 'NotFound', message: '', errno: 'NFE'}\nconsole.log(err1.toJSON());\n//=\u003e {code: 'NotFound', message: ''}\n```\n\n## Plugins\nCommunity packages that implement adds options through this package.\nIf you want yours listed here open a PR.\n\n* [restify-errors-options-errno](https://github.com/simonepri/restify-errors-options-errno): *Add errno to Restify's errors*\n\n## API\n\n### add(optName, [optDefault])\n\nAdds custom options to errors' body.\n\n#### optName\n\nType: `string`\n\nName of the option key to add.\n\n#### optDefault\n\nType: `(number|boolean|string|object)`\n\nDefault value for the option.\nYou can also provide a function, see the next section.\n\n#### optDefault(errorCode, errorHttpCode, errorMessage)\n\nType: `function`\n\nReturns the default value for the option using parameters of the error.\n\n### delete(optName)\n\nRemoves previously added custom options..\n\n#### optName\n\nType: `string`\n\nName of the option key to remove.\n\n## Authors\n* **Simone Primarosa** - [simonepri](https://github.com/simonepri)\n\nSee also the list of [contributors](https://github.com/simonepri/restify-errors-options/contributors) who participated in this project.\n\n## License\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonepri%2Frestify-errors-options","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonepri%2Frestify-errors-options","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonepri%2Frestify-errors-options/lists"}