How can I configure error instrumentation for all forest controllers?

Hey! Is there a way to tune how to send errors to our exception manager (for rails)? Like I want to rescue_from in the base forest controller and add context to the error like the user or more details about the request.

Thank you!

Hi @Maicol_Bentancor,

Our rails expert is looking into it and will come back to you asap :wink:

1 Like

Hi @Maicol_Bentancor

The agent uses a custom Reporter to catch exception, but you could create your own reporter to override it. forest-rails/resources_controller.rb at main · ForestAdmin/forest-rails · GitHub

For example :
create the file lib/my_reporter.rb

class MyReporter
  def report (error)
    # you own logic here
    puts "An user has encountered an error: #{error}" 
  end
end

Then into your config/initializers/forest_liana.rb, you need to add the following line to use it.

ForestLiana.reporter = MyReporter.new

However you can’t have access to the current user in this kind of reporter.

Yeah, but doesn’t catch all the errors like middleware ones (rack timeout), so I might need to build one, thank you anyway!