Catching errors

We would like some kind of handler to catch any unhandled errors so we can log them. On our app initialization we have code like.

var app = new Framework7({
  name: 'client-app', 
  theme: 'auto', 
  el: '#app', 
  component: App, 
  id: 'io.framework7.myapp', 
  store: store,
  routes: routes,
  on: {
    init: function () {
    pageInit: function (page) {
      window.onerror = function(e) {
          log('Error happened' + e);

The window.onerror on the pageInit is never called when an error occurs. Is there a better way to handle this?

Funny you should ask. I may need to update this but here’s what I wrote and have been using for about 8 years (in various forms - I’m not sure git has the latest version).

Basically I have a menu item or taphold event that takes me to a /debug/ page and on page init I populate the page with the console.log.

If yours is crashing before then, I’d suggest getting it to work in a browser first.