https://github.com/robertoachar/node-catch-errors
A high-order function to catch errors from promises.
https://github.com/robertoachar/node-catch-errors
async await catch error errors node promises
Last synced: 2 months ago
JSON representation
A high-order function to catch errors from promises.
- Host: GitHub
- URL: https://github.com/robertoachar/node-catch-errors
- Owner: robertoachar
- License: mit
- Created: 2017-09-28T00:53:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-13T18:42:41.000Z (almost 7 years ago)
- Last Synced: 2025-02-02T21:18:47.344Z (3 months ago)
- Topics: async, await, catch, error, errors, node, promises
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/catch-errors
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# catch-errors
Generated by [OSS Project Generator](http://bit.ly/generator-oss-project).
[![NPM Version][npm-badge]][npm-url]
[![License][license-badge]][license-url]> A high-order function to catch errors from promises.
## Installation
Install package
```bash
$ npm install --save catch-errors
```## Usage
```js
const fetch = require('node-fetch');
const catchErrors = require('catch-errors');async function load(username) {
const response = await fetch(`https://api.github.com/users/${username}`);
const user = await response.json();
console.log(user.name);
}const wrappedLoad = catchErrors(load);
wrappedLoad('robertoachar');
```## Development
- Cloning the repo
```bash
$ git clone https://github.com/robertoachar/node-catch-errors.git
```- Installing dependencies
```bash
$ npm install
```- Running scripts
| Action | Usage |
| ------------ | -------------- |
| Linting code | `npm run lint` |# Author
[Roberto Achar](https://twitter.com/robertoachar)
# License
[MIT](https://github.com/robertoachar/node-catch-errors/blob/master/LICENSE)
[npm-badge]: https://img.shields.io/npm/v/catch-errors.svg
[npm-url]: https://www.npmjs.com/package/catch-errors
[license-badge]: https://img.shields.io/github/license/robertoachar/node-catch-errors.svg
[license-url]: https://opensource.org/licenses/MIT