Node.io not throwing error?

170 Views Asked by At

I notice that node.io wasn't throwing any error compare to nodejs, if there's typo. Not sure why. For example:

Running this script contains typo of 'Util2' with node.

var Util = require('./lib/util.js');

console.log(Util2.parseFloat('$123.00'));

Will throw error of:

console.log(Util2.parseFloat('$123.00'));
        ^
ReferenceError: Util2 is not defined.

However, running this script with node.io that have exact same typo doesn't raise any error.

var nodeio = require('node.io');
var Util = require('./lib/util.js');

exports.job = new nodeio.Job({
    input: false,
    run: function () {
        console.log(Util2.parseFloat('$123.00'));
    }
});

Not sure node.io suppress the error message, as without the error message is hard to debug. Any solution?

1

There are 1 best solutions below

0
On BEST ANSWER

Thanks node.io chriso for taking time answering the question. Here's the solution:

Syntax errors should really be filtered out, but for now you have two options

exports.job = new nodeio.Job({
    input: false,
    run: function () {
        console.log(Util2.parseFloat('$123.00'));
    }
  , fail: function (input, err) {
        // handle error here
    }
}); 
or

exports.job = new nodeio.Job({
    input: false,
    run: function () {
        try {
            console.log(Util2.parseFloat('$123.00'));
        } catch (e) {
            //Handle the error here
        }
    }
});

Full Answer