In order to understand some errors, it is better to have the context that generated them (the params in a controller action, the arguments sent to a job, etc). The code line and stack trace are great, but you need to go after all your registers to understand which record generated that bug, etc.
I totally understand that you are trying to keep the gem as simple as possible, and as is stated in the README:
The goal is to provide a simple, lightweight, and performant solution for tracking exceptions in your Rails application. If you need more features, you should probably use a 3rd party service
I added this information using using the Rails.error.set_context with codes like:
class ApplicationController < ActionController::Base
before_action { Rails.error.set_context(params: params) }
end
and
class ApplicationJob < ActiveJob::Base
before_perform do |job|
Rails.error.set_context(arguments: job.arguments)
end
end
It worked for the controllers, but for the jobs, active record objects were saved in the context as just a String with their class name, which makes them useless.
I saw the "sanitizer" code, and I can see you chose to create this string instead of, for example, calling the Object#inspect. I have two separate question for this issue:
- Is there any reason no not use #inspect instead of creating the errors as just the class name?
- What do you think about improving the context identification in the gem itself? Would this go beyond the scope you initially imagined?
In order to understand some errors, it is better to have the context that generated them (the params in a controller action, the arguments sent to a job, etc). The code line and stack trace are great, but you need to go after all your registers to understand which record generated that bug, etc.
I totally understand that you are trying to keep the gem as simple as possible, and as is stated in the README:
I added this information using using the Rails.error.set_context with codes like:
and
It worked for the controllers, but for the jobs, active record objects were saved in the context as just a String with their class name, which makes them useless.
I saw the "sanitizer" code, and I can see you chose to create this string instead of, for example, calling the Object#inspect. I have two separate question for this issue: