The Kris Kowal's Q docs states that Q.onerror
is invoked on unhandled exceptions.
I can't make it work:
var Q = require('q');
Q.longStackSupport = true;
var util = require('util');
Q.onerror=function(){
console.log('Q.onerror::')
console.log(util.inspect(arguments))
}
function get(){
var def=Q.defer();
def.resolve('resolved');
return def.promise;
}
get()
.then(function(val){
console.log('ok:'+val)
undefined._prop; // i would expect this exception to be
// forwarded to Q.onerror... but it doesn't
console.log('not reachd')
});
outputs:
ok:resolved
I think I didn't understand well the use of Q.onerror
I'd like to track unhandled exceptions (and possibly rejections too) with a nice stack trace