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

Inspect an Exception object like a normal object in Firefox dev tools

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

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

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

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

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

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