gpt4 book ai didi

javascript - 在 Firefox 开发工具中像检查普通对象一样检查异常对象

转载 作者:行者123 更新时间:2023-12-02 21:24:31 26 4
gpt4 key购买 nike

我正在尝试调试抛出并捕获异常的问题。当我将其记录到控制台时,Firefox 显示它与普通对象完全不同:

enter image description here

我可以通过执行 JSON.parse(JSON.stringify(e)) 来强制它像普通对象一样显示,但是有没有更简单的方法呢?

最佳答案

当您在catch block 中设置断点时,您可以使用Debugger panel 侧边栏中的Scopes 面板查看异常的属性。 .

在该面板中,当前堆栈帧的所有对象都显示在 block 范围下。

Exception object

除此之外,我现在还创建了一个 enhancement request asking to add a way to display an exception's properties within the console .

PS:要记录错误,您可以使用 console.error()而不是 console.log()

关于javascript - 在 Firefox 开发工具中像检查普通对象一样检查异常对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60769647/

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