https://github.com/coderaiser/try-catch
Try-catch wrapper
https://github.com/coderaiser/try-catch
catch javascript nodejs try-catch
Last synced: 13 days ago
JSON representation
Try-catch wrapper
- Host: GitHub
- URL: https://github.com/coderaiser/try-catch
- Owner: coderaiser
- License: mit
- Created: 2014-12-19T15:10:06.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2025-12-31T12:01:43.000Z (about 1 month ago)
- Last Synced: 2026-01-03T20:12:49.123Z (about 1 month ago)
- Topics: catch, javascript, nodejs, try-catch
- Language: JavaScript
- Homepage: https://gist.github.com/coderaiser/a26e535bc43b5fe1ac4d72624bd6bed2
- Size: 128 KB
- Stars: 19
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog
- License: LICENSE
Awesome Lists containing this project
README
# Try Catch [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
[NPMIMGURL]: https://img.shields.io/npm/v/try-catch.svg?style=flat
[NPMURL]: https://npmjs.org/package/try-catch "npm"
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
[CoverageURL]: https://coveralls.io/github/coderaiser/try-catch?branch=master
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/try-catch/badge.svg?branch=master&service=github
[BuildStatusURL]: https://github.com/coderaiser/try-catch/actions?query=workflow%3A%22Node+CI%22 "Build Status"
[BuildStatusIMGURL]: https://github.com/coderaiser/try-catch/workflows/Node%20CI/badge.svg
Functional `try-catch` wrapper
## Install
```
npm i try-catch
```
## Example
```js
import {tryCatch} from 'try-catch';
const {parse} = JSON;
const [error, result] = tryCatch(parse, 'hello');
if (error)
console.error(error.message);
```
## Related
- [try-to-catch](https://github.com/coderaiser/try-to-catch "TryToCatch") - functional try-catch wrapper for promises.
## License
MIT