I noticed a strange behavior while defining custom error objects in Javascript:
function MyError(msg) { Error.call(this, msg); this.name = \"MyError\
In Node.js you can create a custom error like this:
var util = require('util'); function MyError(message) { this.message = message; Error.captureStackTrace(this, MyError); } util.inherits(MyError, Error); MyError.prototype.name = 'MyError';
See captureStackTrace in node docs