gpt4 book ai didi

node.js - Error.captureStackTrace 不再适用于最新版本的 nodejs (v0.6.11)。是不是被换了?

转载 作者:搜寻专家 更新时间:2023-10-31 23:49:43 27 4
gpt4 key购买 nike

我最近从 nodejs v0.4.9 更新到 v0.6.11 并注意到我的堆栈跟踪没有显示出来。我依靠其中的一些来验证测试。任何人都知道这是怎么回事,或者是否有其他方法可以做到这一点?

最佳答案

今天(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 属性。

关于node.js - Error.captureStackTrace 不再适用于最新版本的 nodejs (v0.6.11)。是不是被换了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9399809/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com