I am standardizing all my callbacks to do proper exception handling, but
the only type of exceptions I can't seem to catch in a good way are the
ones illustrated below. When I make a call to a module function which
doesn't exist the exception is not caught anywhere even though I have the
uncaughtExeption handler.

Can anyone explain my what is the best way to catch this, and why this
exception isn't reported to me? The only solution I found is to put a
try/catch phrase around the module function call, but this is not a proper
solution, because you make these kind of errors by accident. I don't want
to put a try/catch clause around every module function I call just to make
sure i don't have a typo.

These kind of errors are really annoying me since I don't get any
notification so often I am searching in the wrong places.

Errorfun is just an empty module in this example.

Thijs


var assert = require('assert');
var errorfun = require('./errortestmodule');
var step = require('step');

process.on('uncaughtException', function(err) {
console.log("___________ UNCAUGHT _____________\n");
console.log(err.message);
 console.log(err.stack);
});

process.on('exit', function () {
console.log('About to exit.');
});

function callNonexistant(callback){
setTimeout(errorfun.nonexitant, 1000);
}

function doSomethingAsync(callback){
 step(
function(){
callNonexistant(this);
 },
function(err){
if(err) return callback(err);
 callback(null);
}
);
}

function myCallback(err, result){
if(err) throw err;
console.log("Finished and happy");
}


doSomethingAsync(myCallback);

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to