JSPM

  • Created
  • Published
  • Downloads 62
  • Score
    100M100P100Q67886F
  • License BSD-2-Clause

A simple function wrapper for ignoring errors thrown.

Package Exports

  • @trenskow/fail-silently
  • @trenskow/fail-silently/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@trenskow/fail-silently) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@trenskow/fail-silently

A simple function wrapper for ignoring errors thrown.

Usage

You wrap the function you want to ignore errors thrown from as the example below.

const
    failSilently = require('@trenskow/fail-silently');

function myThrowingFunction(shouldThrow) {
    if (shouldThrow) throw new Error("This is my error.");
    return 'Hello, World!';
}

failSilently(myThrowingFunction)(false); // -> 'Hello, World!'
failSilently(myThrowingFunction)(true); // -> undefined

It also works with async functions.

LICENSE

See license in LICENSE