具有Sentry的Vue CLI 3-如何使用Vue的config.errorHandler?

杰伊

如何将Vue的config.errorHandlerSentry 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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章