Skip to content
A high-order function to catch errors from promises.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.editorconfig
.eslintignore
.eslintrc
.gitattributes
.gitignore
.npmrc
.prettierrc
CHANGELOG.md
LICENSE
README.md
package.json

README.md

catch-errors

Generated by OSS Project Generator.

NPM Version License

A high-order function to catch errors from promises.

Installation

Install package

$ npm install --save catch-errors

Usage

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
$ git clone https://github.com/robertoachar/node-catch-errors.git
  • Installing dependencies
$ npm install
  • Running scripts
Action Usage
Linting code npm run lint

Author

Roberto Achar

License

MIT

You can’t perform that action at this time.