Reducing Noisy JavaScript Errors with Rollbar

The docs didn't make it very clear exactly what I should do so here is my fix

Recently on a project we were getting lots of noisy JavaScript errors caused by a specific issue with the Safari browser over which we had no control. Rollbar has a config option which allows you to ignore specific error messages which was perfect. The issue was I just couldn’t get it formatted correctly, so I thought it would be useful to share how I got it working.

It seemed like I need to pass the error message string with any characters that needed to be escaped escaped (Here is a link for the full documentation about ignoring specific exception messages). This was not working for me. When I made the string into a regex I was able to get it working.

Here is my code for browser JS:

  var _rollbarConfig = {
    accessToken: ... // Other config code
    ignoredMessages: [/undefined is not an object \(evaluating 'r\[\"@context\"\]\.toLowerCase'\)/]
  };

Recent posts View all

Web Dev

Creating draft posts in Jekyll

How to create and develop with draft posts in Jekyll

Ruby

Forcing a Rails database column to be not null

How you can force a table column to always have something in it with Rails