1.1.5 • Published 5 years ago

funcx v1.1.5

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

funcX

Catch javascript errors easily

install:

$ npm install funcx

##requiring: if you want also using "Method 1"

const funcx = require("funcx")(Function);

else :)

const funcx = require("funcx")();

Method 1:

Catch errors with this syntax:

[yourFunction].funcx([arguments])("callback function")

example

const funcx=require("funcx")(Function);

function sum(a,b,c) {
    console.log(a+b+c);
}

sum.funcx(1,5,7);

and outout of this code is: 13, if any errors occurred you can catch it like this:

const funcx=require("funcx")(Function);

function sum(a,b,c) {
    console.log(a+b+c,d);
}

sum.funcx(1,5,7)(err=>{
    console.log(err)
});

output:

ReferenceError: d is not defined
    at sum.....

Returned error is an object that like returned "e" in try/catch. so you can use

err.name
err.message
...

Method 2:

like Method 1 but in different syntax:

funcx(yourfunction)(arguments)("callback function");

example

const funcx=require("funcx")();

function sum(a,b,c) {
    console.log(a+b+c,d);
}

funcx(sum)(3,4,7)(err=>{
    console.log(err)
});

Method 3:

catch errors near function instead when calling it:

example

  const funcx=require("funcx")(Function);
  
  function sum(a,b,c) {
      console.log(a+b+c,d);
  }
  
  sum.onErr=function(err){   ///when error occurred, this function called
      console.log(err)
  };
  
  funcx(sum)(3,4,7);
  
  /// or
  
  sum.funcx(3,4,5);
1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago