我最近从nodejs v0.4.9更新到v0.6.11,并注意到我的堆栈跟踪没有显示出来。我依赖其中的一些来进行验证测试。有人知道是怎么回事吗?或者有没有不同的方法?
发布于 2013-11-09 14:42:01
今天(2013年11月9日)使用Node v0.10.5进行了测试,这是可行的:
var ParseError = exports.ParseError = function(message) {
Error.captureStackTrace(this, ParseError);
this.message = message;
}
ParseError.prototype = Object.create(Error.prototype);
ParseError.prototype.constructor = ParseError;
当抛出new ParseError('some message')
时,它在被捕获时会像预期的那样携带stack
属性。
https://stackoverflow.com/questions/9399809
复制相似问题