title: How to capture all the errors thrown in Vue.JS SPA
body: <p>I am creating a webapp and trying to capture all the errors thrown anywhere in the vue.js webapp.</p>
  <p>I was looking at <a href="https://v2.vuejs.org/v2/api/#errorHandler" rel="nofollow noreferrer">errorHandler</a> but it only captures error during render or watchers, as stated:</p>
  <blockquote>
  <p>Assign a handler for uncaught errors during component render and watchers. The handler gets called with the error and the Vue instance.</p>
  </blockquote>
  <p>Getting cue from this <a href="https://stackoverflow.com/questions/6970475/get-all-javascript-errors-on-page-javascript-error-handling">question</a>, I wrote following code:</p>
  <pre><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)
  })
  </code></pre>
  <p>Above both gets called but I don't any details of the errors with these. in all the cases I get <code>errorMessage</code> as <code>script error</code></p>
  <p>What can be better way to get details of all the errors and send it to some centralised place like <a href="https://sentry.io/for/vue/" rel="nofollow noreferrer">sentry</a>.</p>