{"id":23072838,"url":"https://github.com/oda2/using-try-catch","last_synced_at":"2026-02-22T04:02:19.672Z","repository":{"id":39874203,"uuid":"366722629","full_name":"Oda2/using-try-catch","owner":"Oda2","description":"Simplify the use of try-catch","archived":false,"fork":false,"pushed_at":"2026-02-20T04:46:37.000Z","size":514,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-02-20T08:40:42.438Z","etag":null,"topics":["await","promise","try-catch","try-catch-js","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/Oda2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"code_of_conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-05-12T13:20:21.000Z","updated_at":"2026-02-20T04:44:45.000Z","dependencies_parsed_at":"2024-01-24T23:45:52.652Z","dependency_job_id":"1476e591-2863-49ad-a5ca-c9c9f2322248","html_url":"https://github.com/Oda2/using-try-catch","commit_stats":{"total_commits":43,"total_committers":5,"mean_commits":8.6,"dds":0.3023255813953488,"last_synced_commit":"6107525fc24080b49409fd63a7a400a53882cde8"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/Oda2/using-try-catch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oda2%2Fusing-try-catch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oda2%2Fusing-try-catch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oda2%2Fusing-try-catch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oda2%2Fusing-try-catch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Oda2","download_url":"https://codeload.github.com/Oda2/using-try-catch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oda2%2Fusing-try-catch/sbom","scorecard":{"id":104096,"data":{"date":"2025-08-11","repo":{"name":"github.com/Oda2/using-try-catch","commit":"8b831c149fe95903f84dadc9c14ddf330413681f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.2,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/22 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: SECURITY.md:1","Info: Found linked content: SECURITY.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1","Info: Found text in security policy: SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:29","Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:28","Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1","Warn: no topLevel permission defined: .github/workflows/main.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":4,"reason":"dependency not pinned by hash detected -- score normalized to 4","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/Oda2/using-try-catch/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/Oda2/using-try-catch/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:56: update your workflow using https://app.stepsecurity.io/secureworkflow/Oda2/using-try-catch/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:70: update your workflow using https://app.stepsecurity.io/secureworkflow/Oda2/using-try-catch/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/Oda2/using-try-catch/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/Oda2/using-try-catch/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/Oda2/using-try-catch/main.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/Oda2/using-try-catch/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/Oda2/using-try-catch/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/Oda2/using-try-catch/release.yml/main?enable=pin","Info:   0 out of   9 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   2 out of   2 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":7,"reason":"SAST tool detected but not run on all commits","details":["Info: SAST configuration detected: CodeQL","Warn: 0 commits out of 11 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"10 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-xffm-g5w8-qvg7","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-67mh-4wv8-2f99","Warn: Project is vulnerable to: GHSA-vg6x-rcgg-rjx6","Warn: Project is vulnerable to: GHSA-x574-m823-4x7w","Warn: Project is vulnerable to: GHSA-4r4m-qw57-chr8","Warn: Project is vulnerable to: GHSA-xcj6-pq6g-qj4x","Warn: Project is vulnerable to: GHSA-356w-63v5-8wf4","Warn: Project is vulnerable to: GHSA-859w-5945-r5v3","Warn: Project is vulnerable to: GHSA-9crc-q9x8-hgqq"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-15T10:45:50.506Z","repository_id":39874203,"created_at":"2025-08-15T10:45:50.506Z","updated_at":"2025-08-15T10:45:50.506Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29704420,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T03:17:42.375Z","status":"ssl_error","status_checked_at":"2026-02-22T03:17:31.622Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["await","promise","try-catch","try-catch-js","typescript"],"created_at":"2024-12-16T07:27:31.057Z","updated_at":"2026-02-22T04:02:19.663Z","avatar_url":"https://github.com/Oda2.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"assets/logo.png\" alt=\"using-try-catch\" width=\"200\" /\u003e\n  \u003ch1\u003eusing-try-catch\u003c/h1\u003e\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/using-try-catch\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/using-try-catch?color=EA4335\u0026label=npm\u0026style=flat-square\" alt=\"npm version\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/using-try-catch\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dt/using-try-catch?color=28A745\u0026style=flat-square\" alt=\"npm downloads\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/Oda2/using-try-catch/actions/workflows/ci.yml\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/Oda2/using-try-catch/ci.yml?color=9B59B6\u0026label=CI\u0026style=flat-square\" alt=\"tests\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://opensource.org/licenses/MIT\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/l/using-try-catch?color=A32E27\u0026style=flat-square\" alt=\"license\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e A tiny utility that simplifies try-catch handling in JavaScript/TypeScript. No more repetitive try-catch blocks for every async operation.\n\n## Why?\n\nHandling errors with async/await often leads to verbose code:\n\n```js\nconst fetchData = async () =\u003e {\n  let data;\n  let error;\n\n  try {\n    data = await api.get('/user');\n  } catch (err) {\n    error = err;\n  }\n\n  if (error) return handleError(error);\n  return processData(data);\n};\n```\n\n## Quick Start\n\n```bash\nnpm install using-try-catch\n```\n\n```js\nimport usingTryCatch from 'using-try-catch';\n\nconst fetchData = async () =\u003e {\n  const { data, error } = await usingTryCatch(api.get('/user'));\n\n  if (error) return handleError(error);\n  return processData(data);\n};\n```\n\nThat's it! Returns `{ data, error }` - always.\n\n## Features\n\n- **Zero dependencies** - Ultra lightweight\n- **TypeScript support** - Fully typed out of the box\n- **Universal** - Works in Node.js and browsers\n- **Flexible** - Handles single or multiple promises\n\n## Usage\n\n### Single Promise\n\n```js\nconst { data, error } = await usingTryCatch(fetchUser());\n\nif (error) {\n  console.log('Failed:', error.message);\n  return;\n}\n\nconsole.log('User:', data.name);\n```\n\n### Multiple Promises (Parallel)\n\n```js\nconst { data, error } = await usingTryCatch([\n  fetchUser(),\n  fetchPosts(),\n  fetchComments()\n]);\n\nif (error) {\n  console.log('One or more requests failed');\n  return;\n}\n\nconst [user, posts, comments] = data;\n```\n\n## API\n\n```ts\nusingTryCatch\u003cT\u003e(promise: Promise\u003cT\u003e | Promise\u003cT\u003e[]): Promise\u003c{\n  data: T | T[] | null;\n  error: unknown;\n}\u003e\n```\n\n- Returns an object with `data` and `error` properties\n- `error` is `null` on success, unknown on failure\n- Works with single promises or arrays of promises\n\n## TypeScript\n\nFully typed out of the box:\n\n```ts\nimport usingTryCatch from 'using-try-catch';\n\nconst { data, error } = await usingTryCatch(fetchUser());\n// data is typed as User | User[] | null\n// error is typed as unknown\n```\n\n## Requirements\n\n- Node.js \u003e= 18\n\n## Browser\n\nLoad via CDN:\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/using-try-catch/dist/esm/using-try-catch.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  const { data, error } = await usingTryCatch(fetch('/api/data'));\n\u003c/script\u003e\n```\n\n## Contributing\n\nContributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.\n\n\u003ca href=\"https://github.com/Oda2/using-try-catch/issues\"\u003e\n  \u003cimg src=\"https://img.shields.io/github/issues/Oda2/using-try-catch?color=FF6B6B\u0026style=flat-square\" alt=\"issues\" /\u003e\n\u003c/a\u003e\n\n## License\n\nMIT - See [LICENSE](LICENSE) for details.\n\n---\n\n\u003cp align=\"center\"\u003e\n  Made with ❤️ by \u003ca href=\"https://twitter.com/renato_oda\"\u003eRenato Oda\u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foda2%2Fusing-try-catch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foda2%2Fusing-try-catch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foda2%2Fusing-try-catch/lists"}