greatergreg
greatergreg

Reputation: 31

Error.captureStackTrace no longer works with the latest version of nodejs (v0.6.11). Was it replaced?

I recently updated from nodejs v0.4.9 to v0.6.11 and noticed none of my stack traces were showing up. I depended on a few of those to for validating tests. Anyone know whats up or if theres a different way to do it?

Upvotes: 3

Views: 4297

Answers (1)

Eli Bendersky
Eli Bendersky

Reputation: 273546

Tested today (Nov 9, 2013) with Node v0.10.5, this works:

var ParseError = exports.ParseError = function(message) {
  Error.captureStackTrace(this, ParseError);
  this.message = message;
}

ParseError.prototype = Object.create(Error.prototype);
ParseError.prototype.constructor = ParseError;

When new ParseError('some message') is thrown, it carries the stack attribute as expected when caught.

Upvotes: 3

Related Questions