如何将Vue的config.errorHandler与Sentry for Vue结合使用?
除了应用程序中的Sentry之外,我还想捕获其他错误,但是一旦实现config.errorHandler,我就会覆盖Sentry实现。
main.js:
import * as Sentry from "@sentry/browser";
Sentry.init({
dsn: "my dsn",
integrations: [new Sentry.Integrations.Vue({ Vue })]
});
// This prevents sentry from being used
Vue.config.errorHandler = (msg, vm , info) => {
alert(info)
}
当Sentry覆盖时Vue.config.errorHandler
,它将保存对先前声明的引用,errorHandler
并在Sentry处理错误后调用该引用。资源
在这种情况下,errorHandler
应在将Vue
构造函数传递到之前声明自定义new Sentry.Integrations.Vue({ Vue })
。
对于上面的代码示例,简单地切换自定义的顺序errorHandler
,并Sentry.init()
应解决的问题。
import * as Sentry from "@sentry/browser";
Vue.config.errorHandler = (msg, vm , info) => {
alert(info)
}
Sentry.init({
dsn: "my dsn",
integrations: [new Sentry.Integrations.Vue({ Vue })]
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句