How to capture all the errors that occurred in Vue.JS SPA

I am creating a webapp and trying to capture all the errors thrown anywhere in vue.js webapp.

I watched errorHandler , but it only fixes the error during rendering or observers, as indicated:

Assign a handler for unverified errors during component and observer rendering. The handler is called with an error and a Vue instance.

Having received the answer from this question , I wrote the following code:

window.onerror = function (errorMsg, url, lineNumber, column, errorObj) { console.log('Inside window.onerror') console.log(errorMsg, ' ', url, ' ', lineNumber, ' ', column, ' ', errorObj) return false } window.addEventListener('error', function (e) { console.log('Inside error Listener', e.message) }) 

Both are called above, but I don't see any details about the errors. in all cases, I get errorMessage as a script error

What could be the best way to get information about all errors and send it to some centralized place, such as sentry .

+6
source share
1 answer

You mentioned Sentry in your answer, and if your goal is to log errors, all you need to add is Raven.js and the Vue plugin.

Sentry has documentation about this here: https://docs.sentry.io/clients/javascript/integrations/vue/

+1
source

Source: https://habr.com/ru/post/1015058/


All Articles