[英]Unhandled exception event handler not called when exception is thrown from Express routes
[英]unhandled exception handler missing exception info
与在这个问题中提出的问题类似,我试图将所有未处理的错误推送到我们的遥测管道,以便为工程师提供足够的信息来调试问题。
未处理的异常处理程序以下列方式设置:
window.onerror = (event: Event | string, source?: string, lineno?: number, colno?: number, error?: Error) => {
const message: string = `src: ${source} line: ${lineno} col: ${colno}`;
logError(error || new Error(event.toString()), message);
};
这似乎与文档一致。
在遥测开始流动后,我观察到以下内容:
error
变量是 null。lineno
和colno
也是null
或0
。我知道CROSSORIGIN设置,它似乎设置正确。
我找不到任何严格的规则来描述在未处理的回调期间提供的信息。 我也在寻找有关我们设置未处理回调的方式的反馈以及潜在改进的想法。
<script type="text/javascript">
window.onerror = function(msg, url, line, col, error) {
const message: string = `src: ${source} line: ${lineno} col: ${colno}`;
logError(error || new Error(event.toString()), message);
// Send your telemetry info here
// Many browsers show alerts dialogs when errors are founded, so return true to suppress it.
return true;
};
</script>
该事件在以下任一情况下引发
例如:
未捕获的异常
编译错误
<script>{</script>
<script>for(;)</script>
<script>"oops</script>
setTimeout("{", 10);, it will attempt to compile the first argument as a script
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.