wraperr

1.0.1 • Public • Published

wraperr

A light wrapper around the top level of CPS functions that calls either a success or error callback based on the arguments passed.

npm i wraperr

EG:

var wraperr = require('wraperr');

...

function doSomeThing(callback){
    ...
    if(!worked){
        callback(error);
    }else{
        callback(null, result);
    }
}

...

"someRoute": function(request, response){

    // Assume some kind of setup of
    // respondWithOK and respondWithError here

    ...

    doSomeThing(wraperr(respondWithOK, respondWithError));
}

Warning

This function is intended only to be used when you have a distinct way to handle the error, not around all CPS functions.

Readme

Keywords

none

Package Sidebar

Install

npm i wraperr

Weekly Downloads

414

Version

1.0.1

License

ISC

Last publish

Collaborators

  • korynunn