ruby-on-railsrollbar

Ruby on Rails sending 500 errors to Rollbar in a properly way


In my Rails app I'm rescuing from all possible error, therefore it's possible that some 500 are not correctly sent to Rollbar and I want to fix it. I'm reviewing the documentation but without a meaningful answer.

Edit:

To be more clear, I have couple methods where I can handle all errors but in one place I've got something like this:

rescue_from :all do |error|
        title = Rails.env.production? ? 'Error 500' : error.message
        Rollbar.notify
        render_jsonapi_errors(
          title: title,
          status: 500,
          error: error
        )
      end

And I think I have to add some logic because in this case I don't send this message to rollbar because of this rescue_from :all (I cannot just delete this). Is there something like Rollbar.notify ?

Edit2:

After adding Rollbar.notify I don't see that app is trying to connect to the Rollbar

Output from rails s

Started GET "/" for 127.0.0.1 at 2019-05-17 17:09:56 +0200

NameError - uninitialized constant ApplicationController::ActionVew:
app/controllers/application_controller.rb:4:in <class:ApplicationController>'
app/controllers/application_controller.rb:3:in
'
app/controllers/root_controller.rb:3:in `'

Started POST "/__better_errors/5b518f578013d9ea/variables" for 127.0.0.1 at 2019-05-17 17:09:56 +0200


Solution

  • The better_errors gem (shown in your output) swallows errors in development mode.

    It's a common-enough problem that we have a section of our Honeybadger documentation specifically for it: https://docs.honeybadger.io/lib/ruby/support/troubleshooting.html#the-better_errors-gem-is-installed