SaltwaterC/libxml-to-js — Issue #8: Error Handling
Author: kongelaks
Created: 2011-10-11 21:29:17+00:00
State: open

I'm just wondering why you execute the xml parsing/callback inside of a try block and then catch it with:

} catch (err) {
err.message = err.message || 'libxml error';
var errInst = new Error(err.message);
errInst.code = err.code || 0;
callback(errInst);
}

err contains a stack trace which is very valuable for debugging (at least when the user of the library throws an error after converting xml to js). However, the stack trace is lost in this catch block when transferring properties of err to errInst. What's wrong with doing

} catch (err) {
err.message = err.message || 'libxml error';
err.code = err.code || 0;
callback(err);
}

?