I've tried stuff like this before, but it clutters your code pretty bad anyway, doesn't it? You have to do something like this:
function myAsyncThing(cb) {
var handleErrors = errHandler(cb)
doSomethingElse(handleErrors(function(data) {
// repeat. use handleErrors at each callback.
}))
}
Am I missing something? Can you get it cleaner than that?
If you're using Node you should be writing small(ish) modules anyways, so it doesn't lead to much code blote and its advantageous to consolidate your error handling in one or 2 spots.