Error when catch exceptions in Vue components
See original GitHub issueDo you want to request a feature or report a bug?
bug
What is the current behavior?
I’m using Chrome 60. I’m adding Sentry support to Vue SPA, using Raven 3.17.0. I install Raven from npm and init it in my index.js, right before creating Vue application, i.e.
import Vue from 'vue'
import Raven from 'raven-js'
import RavenVue from 'raven-js/plugins/vue'
Raven.config('... our company dsn ...').addPlugin(RavenVue, Vue).install()
new Vue({
el: '#app',
... etc.
Then I throw some exceptions in code, like
throw new Error('test exception')
Raven catches and log exceptions only in my main Vue instance methods. Any other errors in components, modules, etc. cause this error in console
TypeError: Cannot read property '$root' of undefined
at formatComponentName (eval at <anonymous> (client.js:3430), <anonymous>:8:11)
at VueErrorHandler (eval at <anonymous> (client.js:3430), <anonymous>:28:28)
at handleError (eval at <anonymous> (client.js:766), <anonymous>:513:25)
at Array.eval (eval at <anonymous> (client.js:766), <anonymous>:654:11)
at nextTickHandler (eval at <anonymous> (client.js:766), <anonymous>:599:16)
at <anonymous>
For example:
new Vue({
el: '#app',
store,
data() { return {...} },
router,
render: h => h(app),
methods: {
testMethod() {
// debug exception for Sentry
throw new Error('test exception')
}
}})
This works. Test error is logged in Sentry.
Same throw in any other components methods cause error.
What is the expected behavior?
Log any uncaught exceptions in code, don’t cause errors.
Am I doing something wrong?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Error/Exception handling in Vue.js application | by Arun Redhu
For error handling, we can assign a handler function to Vue.config.errorHandler . The handler gets called for any uncaught exceptions within any ...
Read more >Vue Error Handling - Mastering JS
Vue instances have an errorCaptured hook that Vue calls whenever an event handler or lifecycle hook throws an error.
Read more >Error handling, debugging, and tracing in Vue.js
In this tutorial, we'll demonstrate how to handle errors, set up a debugger, and trace errors efficiently in Vue.js.
Read more >Error and Exception handling in Vue.js applications - Lavalite
To handle errors we can assign a handler function to Vue. config. errorHandler. If there are any uncaught exceptions the handler gets called....
Read more >Best Practice in Error Handling in Vuejs With Vuex and Axios
What I want to do is, If there's an response error from my request it will return to my component so that I...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Dewep you’re totally right. This should do now https://github.com/getsentry/raven-js/pull/1118 😃
Well, I’m not sure that’s the perfect solution. As you would expect, RavenJS doesn’t crash anymore, but the error is not reported. We would like to be informed when the application is dead for our customers. 😃