-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
全局错误在哪捕获? #2756
Comments
Translation of this issue: Where is the global error captured?I looked at the documentation for [Exception Handling] (https://eggjs.org/zh-cn/core/error-handling.html) but didn't find a way to capture global errors. After installing Can the document be written more clearly? |
Hello @musicode. Please provide a reproducible example by creating a github repo. Issues labeled by |
我也很无奈,issue 能否写的更清楚一些呢?不是有 template 提示必须的内容么? |
这个 issue 不是具体的 bug,我觉得应该没必要写环境版本之类的吧? 我处理错误的方式是 |
|
一般这种处理,不是在 egg 层做的,而是应该在日志采集分析层去做。因为一般集群多机情况下,日志采集回去后要做汇总分析才出告警的,这个有很多分析系统是可以直接用的。 |
多谢了,首先抱歉的是,我确实不太愿意去新建一个仓库,当然从你们的角度,这样做是最友好的。 我的配置其实很简单,在 exports.onerror = {
enable: true,
package: 'egg-onerror',
} 然后在 config.onerror = {
all(err, ctx) {
console.log(err)
}
} 然后抛一个错误: throw new Error() 发现并没有打印。 现在我改了一种方式,用 最后,我现在实现比较简单,用了一个第三方的推送服务,只需要拦截错误发个 http 请求即可,所以我暂时先这么处理了,如有不妥,还烦请告知,谢谢了 |
这是节省双方的时间,最高效的交流方式。 像现在我们在 issue 上挤牙膏的交流了快 15 分钟,还是不知道问题出在哪里。 我猜测是应该是你应该还是配置错误了,最常见的那个错误估计:#2088
|
好的,下次我新建项目再提 issue,这次麻烦了 |
如果你在业务代码中写了try catch,那么你配置的onerror就不会执行了 |
我也遇到这个问题了 并且检查了上面说的并没有错 @musicode |
我看了 异常处理 的文档,但没找到一个想要的捕获全局错误的方法。
安装
egg-onerror
之后,在config.default.js
里加了onerror
也没调用,很无奈。文档是否可以写的更清楚些?
The text was updated successfully, but these errors were encountered: