vue.jsvue-componentvuejs3airbrake

Vue.js 3's alternative to `Vue.config.errorHandler`


Airbrake's Vue configuration page is still about Vue 2:

Vue.config.errorHandler = function (err, vm, info) {
  airbrake.notify({
    error: err,
    params: {info: info}
  });
}

What is the equivalent for Vue.js 3?


Solution

  • It's the same in vue 3 with a little change which is the use of Vue instead (instance of createApp()) instance of Vue class :

    import { createApp } from "vue";
    import App from "./App.vue";
    
    let app=createApp(App)
    
    app.config.errorHandler = function (err, vm, info) {
      airbrake.notify({
        error: err,
        params: {info: info}
      });
    }
    app.mount("#app");