Open mcheshkov opened 8 years ago
This is due telling Node to call the processing function via setImmediate
which calls it when the scheduler decides it's time, with no way to pass the exception back to the code that called parseString
in the first place.
If you would like to get that exception, you could have an error handler either in the callback directly or call an error callback from a catch
block in the callback.
I don't want to catch exception, I want proper unhandled exception.
This script
setImmediate(function(){
throw new Error("test");
});
Gives me this in terminal
$ node a && echo "Good" || echo "Bad"
/home/cheshkov/xlsx_temp/a.js:6
throw new Error("test");
^
Error: test
at Immediate._onImmediate (a.js:6:8)
at processImmediate [as _immediateCallback] (timers.js:383:17)
Bad
But xml2js comsume this exception, and leave no trace
var xml2js = require('xml2js');
xml2js.parseString("<a></a>", {async: true}, function(err, res){
throw new Error("test");
});
$ node a && echo "Good" || echo "Bad"
Good
This script does not show any unhandled errors.