{"id":15434047,"url":"https://github.com/sebinsua/catch-to","last_synced_at":"2025-10-24T14:45:08.058Z","repository":{"id":57194955,"uuid":"85616191","full_name":"sebinsua/catch-to","owner":"sebinsua","description":"Catch errors and declaratively map them to other errors or values.","archived":false,"fork":false,"pushed_at":"2017-04-10T16:03:12.000Z","size":52,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-07T09:04:39.034Z","etag":null,"topics":["api","boom","catch","errors","map","promise","value"],"latest_commit_sha":null,"homepage":null,"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/sebinsua.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-03-20T19:12:51.000Z","updated_at":"2017-03-22T19:46:01.000Z","dependencies_parsed_at":"2022-09-16T05:14:12.324Z","dependency_job_id":null,"html_url":"https://github.com/sebinsua/catch-to","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebinsua%2Fcatch-to","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebinsua%2Fcatch-to/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebinsua%2Fcatch-to/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebinsua%2Fcatch-to/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebinsua","download_url":"https://codeload.github.com/sebinsua/catch-to/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240682053,"owners_count":19840434,"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":["api","boom","catch","errors","map","promise","value"],"created_at":"2024-10-01T18:36:52.119Z","updated_at":"2025-10-24T14:45:07.954Z","avatar_url":"https://github.com/sebinsua.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `catch-to`\n\u003e Catch errors and declaratively map them to other errors or values.\n\nThis is useful when you do not wish to expose the specific errors your system\nuses to describe its internal state, and instead want to respond with more general, human-like errors.\n\n## Example\n\n```js\nconst Boom = require('boom')\nconst toErrors = require('catch-to')(Boom.badImplementation)\n\nconst login = require('./login')\nconst {\n  UnauthorizedLoginError,\n  AccountLockedError,\n  TooManyLoginsError,\n  MissingAuthenticityTokenError\n} = require('./errors')\n\nlogin('username', 'password')\n  .catch(\n    toErrors([\n      {\n        on: [ UnauthorizedLoginError, MissingAuthenticityTokenError ],\n        toError: err =\u003e Boom.unauthorized(err)\n      },\n      {\n        on: TooManyLoginsError\n        toError: Boom.badRequest()\n      },\n      {\n        on: AccountLockedError,\n        toError: Boom.locked()\n      }\n    ])\n  )\n```\n\n## API\n\n### `CreateCatchToSignature`: `(fallbackError?: ToErrorSignature, defaultLog?: LogSignature): CatchToSignature`\n\n### `CatchToSignature`: `(errorCategories?: ErrorCategory|Array\u003cErrorCategory\u003e, log?: LogSignature): CatchSignature`\n\n### `CatchSignature`: `(error: Error): Error|any`\n\n### Types\n\n#### `ErrorCategory`: `Array\u003c{ on: Error|Array\u003cError\u003e|ErrorPredicateSignature, toError?: Error|ToErrorSignature, toValue?: any|ToValueSignature }\u003e`\n\n#### `ErrorPredicateSignature`: `(error: Error): boolean`\n\n#### `ToErrorSignature`: `(error: Error): Error`\n\n#### `ToValueSignature`: `(error: Error): any`\n\n#### `LogSignature`: `(message?: string): void`\n\n## Install\n\n```sh\nyarn add catch-to\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebinsua%2Fcatch-to","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebinsua%2Fcatch-to","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebinsua%2Fcatch-to/lists"}