{"id":19151676,"url":"https://github.com/cypress-io/error-message","last_synced_at":"2025-04-19T16:31:56.435Z","repository":{"id":39674696,"uuid":"94424605","full_name":"cypress-io/error-message","owner":"cypress-io","description":"User-friendly error text with additional information","archived":false,"fork":false,"pushed_at":"2017-07-26T15:02:54.000Z","size":14,"stargazers_count":4,"open_issues_count":2,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-09T21:30:18.452Z","etag":null,"topics":["error","exceptions","term","terminal","util"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cypress-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-15T09:39:48.000Z","updated_at":"2022-08-26T14:13:59.000Z","dependencies_parsed_at":"2022-09-20T07:24:10.406Z","dependency_job_id":null,"html_url":"https://github.com/cypress-io/error-message","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cypress-io%2Ferror-message","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cypress-io%2Ferror-message/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cypress-io%2Ferror-message/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cypress-io%2Ferror-message/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cypress-io","download_url":"https://codeload.github.com/cypress-io/error-message/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223800822,"owners_count":17205010,"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":["error","exceptions","term","terminal","util"],"created_at":"2024-11-09T08:15:26.826Z","updated_at":"2024-11-09T08:15:27.496Z","avatar_url":"https://github.com/cypress-io.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @cypress/error-message\n\n\u003e User-friendly error text with additional information\n\n[![NPM][npm-icon] ][npm-url]\n\n[![Build status][ci-image] ][ci-url]\n[![semantic-release][semantic-image] ][semantic-url]\n[![js-standard-style][standard-image]][standard-url]\n\n## Install\n\nRequires [Node](https://nodejs.org/en/) version 0.12 or above.\n\n```sh\nnpm install --save @cypress/error-message\n```\n\nLoad the function from the module\n\n```js\nconst {formErrorText} = require('@cypress/error-message')\n```\n\n## Use\n\nThink about all possible errors your application might encounter.\nDescribe each one and suggest a solution the user should try in case this\nparticular error happens. Then form the full message once the exception\nis caught and show it to the user\n\n```js\nconst fileSaveError = {\n  description: 'We could not save an important file',\n  solution: `Please check folder permissions and try again\n\n    more details on our FAQ page: https://faq.company.name\n  `\n}\nfs.writeFile(name)\n  .catch(\n    formErrorText(info).then(console.error)\n  )\n/*\n  shows nice error message\n\n  ------\n  We could not save an important file\n  Please check folder permissions and try again\n\n    more details on our FAQ page: https://faq.company.name\n\n  Exception message\n  ------\n  Platform: darwin\n  Version: 15.6.2\n*/\n```\n\nIf you want to include the exception stack, pass `printStack` option in\nthe `info` object. For example, a catch-all function should probably print\nstack to give you a good idea where the problem happens.\n\n```js\nconst badError = {\n  description: 'Unexpected error happened',\n  solution: `Something terrible went wrong. Search issues on our\n    GitHub repo to find possible solution: https://github.com/company/repo`,\n  printStack: true\n}\ndoMyStuff()\n  .catch(\n    formErrorText(badError).then(console.error)\n  )\n```\n\nIf `info` argument is missing a description or a solution, an error will be\nthrown.\n\n## Re-throwing a detailed error\n\nYou might not want to handle the error, but rather add details and rethrow\nit. For this there is a helper function\n\n```js\nconst {throwDetailedError} = require('@cypress/error-message')\nconst info = {\n  description: 'error description',\n  solution: 'our solution'\n}\nfoo()\n  .catch(throwDetailedError(info))\n  // later catch this detailed error\n  .catch(err =\u003e {\n    // err has original exception + description and solution\n    console.error(err)\n  })\n```\n\n## Examples\n\n* Reading a file [before](examples/simple/index.js) and [after](examples/simple/after.js)\n\n### Small print\n\nSupport: if you find any problems with this module, email / tweet /\n[open issue](https://github.com/cypress-io/error-message/issues) on Github\n\n## MIT License\n\nCopyright (c) 2017 Cypress.io https://cypress.io\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the \"Software\"), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\n[npm-icon]: https://nodei.co/npm/@cypress/error-message.svg?downloads=true\n[npm-url]: https://npmjs.org/package/@cypress/error-message\n[ci-image]: https://travis-ci.org/cypress-io/error-message.svg?branch=master\n[ci-url]: https://travis-ci.org/cypress-io/error-message\n[semantic-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\n[semantic-url]: https://github.com/semantic-release/semantic-release\n[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg\n[standard-url]: http://standardjs.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcypress-io%2Ferror-message","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcypress-io%2Ferror-message","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcypress-io%2Ferror-message/lists"}