Swallows and rethrows errors in two-args callbacks.
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
README.md
index.js
package.json

README.md

node-swallow

Swallows and rethrows errors in two-args callbacks.

«if you swallow on the 1st date you're guaranteed a 2nd.» @YouPorn

Install

npm -S install node-swallow

Use

var swallow = require('node-swallow');

// ...

fs.readFile('config.json', swallow('while reading configuration file', function (data) {
    // do something with data...
}));

If the first argument of the callback is != null then it's rethrown.
This is useful when you want to avoid handling errors-that-should-never-happen or errors that should cause your process to die (e.g.: redis connection errors, database errors,...).

License

See LICENSE.