JS如何将window.error中的Error对象转成字符串?
JS how to convert to string the Error Object from the window.error?
我实现了:
window.onerror = function (m, s, l, c, e) {
}
其中 e 是错误对象。例如,它包含:
ReferenceError: rde is not defined
at Object.bla.cs (domain.pt/bla.js:418:17)
at n.aanv (domain.pt/bla.js:125:29)
如果我e.toString()
,只返回第一行。如何获得3条线?谢谢。
似乎错误对象有一个属性 调用堆栈。所以,e.stack 是错误的全文。
错误对象有一个 .message
属性 包含完整消息(不需要 .toString()
。还有 .stack
但它不是标准化的 属性.
我实现了:
window.onerror = function (m, s, l, c, e) {
}
其中 e 是错误对象。例如,它包含:
ReferenceError: rde is not defined
at Object.bla.cs (domain.pt/bla.js:418:17)
at n.aanv (domain.pt/bla.js:125:29)
如果我e.toString()
,只返回第一行。如何获得3条线?谢谢。
似乎错误对象有一个属性 调用堆栈。所以,e.stack 是错误的全文。
错误对象有一个 .message
属性 包含完整消息(不需要 .toString()
。还有 .stack
但它不是标准化的 属性.