I had a node.js (v0.8.15, latest stable) program crash, with the only output being:
timers.js:103
if (!process.listeners('uncaughtException').length) throw e;
^
undefined
Thinking I'd use the uncaughtException
listener to dig deeper, I registered a trivial callback:
process.on('uncaughtException', function() {
console.log(arguments)
})
However, the only output I get now when the process crashes is:
{ '0': undefined }
There's no Exception object, no stack trace, no message — just good ol' undefined
.
undefined
mean in this context?I figured it out: part of my code was calling throw e
in a context where it might not have been defined, and if you throw an undefined it can't have stack information attached to it or anything.
If anyone else runs into this (or something similar), check your code to see if you might be throwing something that's not an exception. (See the excellent Custom Exceptions in JavaScript question elsewhere on StackOverflow for how you should be throwing one.)