Instrumenting Backbone for better error handling

At work, we’ve been having some issues tracking down some nasty client side bugs. We know they’re happening in our Backbone views, but we’ve been unable to locate them with any more accuracy due to the errors bubbling all the way to the window.onerror handler.

Enter Stackbone. A simple bit of code to instrument Backbone’s event loops to better locate client side errors.

To use:

Stackbone.start({
  Backbone: Backbone
  jQuery: jQuery
  onError: function (err) {
    // ... log the error ...
  }
});

You can use Stackbone = require(‘stackbone’) or simply include the .js file in a script tag. Enjoy!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s