{"id":22059234,"url":"https://github.com/opentable/spur-errors","last_synced_at":"2025-06-17T22:35:31.648Z","repository":{"id":25648772,"uuid":"29084187","full_name":"opentable/spur-errors","owner":"opentable","description":"Common error builder utility for Node.js. Contains common error types, and stack trace tracking to support more detailed error messages.","archived":false,"fork":false,"pushed_at":"2025-05-02T22:55:16.000Z","size":316,"stargazers_count":2,"open_issues_count":4,"forks_count":2,"subscribers_count":26,"default_branch":"main","last_synced_at":"2025-05-12T19:55:39.362Z","etag":null,"topics":["nodejs","npm-package","renovate","spur","spur-framework"],"latest_commit_sha":null,"homepage":"","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/opentable.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":"2015-01-11T07:03:34.000Z","updated_at":"2025-03-06T20:26:34.000Z","dependencies_parsed_at":"2024-04-01T09:26:40.229Z","dependency_job_id":"e337dd5a-dacd-4694-80d0-b47908fadbc5","html_url":"https://github.com/opentable/spur-errors","commit_stats":{"total_commits":79,"total_committers":8,"mean_commits":9.875,"dds":"0.30379746835443033","last_synced_commit":"c7faeacb9b0167c7ce9bb5d1f3cec29fdfed9f06"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fspur-errors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fspur-errors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fspur-errors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fspur-errors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opentable","download_url":"https://codeload.github.com/opentable/spur-errors/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fspur-errors/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":257332496,"owners_count":22529575,"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":["nodejs","npm-package","renovate","spur","spur-framework"],"created_at":"2024-11-30T17:27:41.631Z","updated_at":"2025-06-17T22:35:26.637Z","avatar_url":"https://github.com/opentable.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://opentable.github.io/spur/logos/Spur-Errors.png?rand=1\" width=\"100%\" alt=\"Spur: Errors\" /\u003e\n\nCommon error builder utility for [Node.js](http://nodejs.org/). Contains common error types, and stack trace tracking to support more detailed error messages.\n\n\n  [![NPM Version][npm-version-image]][npm-url]\n  [![NPM Install Size][npm-install-size-image]][npm-install-size-url]\n  [![NPM Downloads][npm-downloads-image]][npm-downloads-url]\n\n# About the Spur Framework\n\nThe Spur Framework is a collection of commonly used Node.JS libraries used to create common application types with shared libraries.\n\n[Visit NPMJS.org for a full list of Spur Framework libraries](https://www.npmjs.com/browse/keyword/spur-framework) \u003e\u003e\n\n# Usage\n\nSupports active Node versions in the [LTS Schedule](https://github.com/nodejs/LTS#lts-schedule). ([view current versions](.travis.yml))\n\n## Install from NPM\n\n```shell\n$ npm install --save spur-errors\n```\n\n## Require and use the module\n\n```javascript\nlet SpurErrors = require(\"spur-errors\");\n\nSpurErrors.NotFoundError.create(\"could not find it\");\n```\n# API\n\nThe API is designed to be daisy chained with all of the following base commands that are a part of all of the error types.\n\n## Base Object Commands\n\n#### .create(message, nativeError) -\u003e instance\n\nCreates an instance of a SpurError for the type used.\n\n```javascript\ntry {\n  ...\n}\ncatch(err) {\n  SpurErrors.NotFound.create(\"Some error\", err);\n}\n```\n\n#### .setErrorCode(errorCode) -\u003e instance\n\nSets an error code to later be used by error handlers.\n\n```javascript\nSpurErrors.NotFound.create(\"Not found\").setErrorCode(\"leaf_error\");\n```\n\n#### .setMessage(message) -\u003e instance\n\nOverrides the error message passed in.\n\n```javascript\nSpurErrors.NotFound.create(\"Not found\").setMessage(\"Unable to find the restaurant.\");\n```\n\n#### .setStatusCode(statusCode) -\u003e instance\n\nSetting the response status code to be sent back down to the client.\n\n```javascript\nSpurErrors.NotFound.create(\"Not found\").setStatusCode(404);\n```\n\n#### .setData(data) -\u003e instance\n\nSets customizable data that can be used down the error stack chain.\n\n```javascript\nSpurErrors.NotFound.create(\"Not found\").setData({headers: req.headers});\n```\n\n## Properties\n\n| Property      | Description                                                                         |\n| :------------ | :---------------------------------------------------------------------------------- |\n| internalError | The original error object passed in                                                 |\n| message       | Either passed in during the create call or during the parsing of the internal error |\n| stack         | Parsed from the originally passed in internal error                                 |\n| errorCode     | Custom error code                                                                   |\n| statusCode    | Custom status code to be used by the Express.JS response                            |\n| data          | Custom data object to be used anyone in the flow                                    |\n\n## Error Types\n\n| Error Type              | Status Code | Message                   | Error Code                |\n| :---------------------- | :---------- | :------------------------ | :------------------------ |\n| ValidationError         | 400         | Validation Error          | validation_error          |\n| UnauthorizedError       | 401         | Unauthorized Error        | unauthorized_error        |\n| ForbiddenError          | 403         | Forbidden Error           | forbidden_error           |\n| NotFoundError           | 404         | Not Found Error           | not_found_error           |\n| MethodNotAllowedError   | 405         | Method not allowed        | method_not_allowed_error  |\n| RequestTimeoutError     | 408         | Request Timeout Error     | request_timeout_error     |\n| AlreadyExistsError      | 409         | Already Exists Error      | already_exists_error      |\n| InternalServerError     | 500         | Internal Server Error     | internal_server_error     |\n| BadGatewayError         | 502         | Bad Gateway Error         | bad_gateway_error         |\n| ServiceUnavailableError | 503         | Service Unavailable Error | service_unavailable_error |\n| GatewayTimeoutError     | 504         | Gateway Unavailable Error | gateway_timeout_error |\n\n### Error type example\n\n```javascript\nSpurErrors.ValidationError.create(\"Invalid input\");\n// =\u003e {statusCode: 400, message: \"Validation Error\", errorCode: \"validation_error\", ....}\n```\n\n# Maintainers\n\nThis library is maintained by\n\n  - Agustin Colchado – ***[@acolchado](https://github.com/acolchado)***\n  - Ray Peters – ***[@ot-raypeters](https://github.com/ot-raypeters)***\n\n## Collaborators\n\n- Ash – ***[@ssetem](https://github.com/ssetem)***\n- Timmy Willison – ***[@timmywil](https://github.com/timmywil)***\n\n\n# Contributing\n\n## We accept pull requests\n\nPlease send in pull requests and they will be reviewed in a timely manner. Please review this [generic guide to submitting a good pull requests](https://github.com/blog/1943-how-to-write-the-perfect-pull-request). The only things we ask in addition are the following:\n\n * Please submit small pull requests\n * Provide a good description of the changes\n * Code changes must include tests\n * Be nice to each other in comments. :innocent:\n\n## Style guide\n\nThe majority of the settings are controlled using an [EditorConfig](.editorconfig) configuration file. To use it [please download a plugin](http://editorconfig.org/#download) for your editor of choice.\n\n## All tests should pass\n\nTo run the test suite, first install the dependancies, then run `npm test`\n\n```bash\n$ npm install\n$ npm test\n```\n\n# License\n\n[MIT](LICENSE)\n\n[npm-downloads-image]: https://badgen.net/npm/dm/spur-errors\n[npm-downloads-url]: https://npmcharts.com/compare/spur-errors?minimal=true\n[npm-install-size-image]: https://badgen.net/packagephobia/install/spur-errors\n[npm-install-size-url]: https://packagephobia.com/result?p=spur-errors\n[npm-url]: https://npmjs.org/package/spur-errors\n[npm-version-image]: https://badgen.net/npm/v/spur-errors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentable%2Fspur-errors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopentable%2Fspur-errors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentable%2Fspur-errors/lists"}