Rails 7.0 will add a standard interface for reporting errors to error tracking services like Sentry (rails/rails#43625).
# Report any error raised and continue execution:
Rails.error.handle do
# ...
end
# Report and re-raise any error:
Rails.error.record do
# ...
end
# Report an error directly:
Rails.error.report(error)
Additionally, Rails’s internal execution wrappers have been updated to report errors via Rails.error.report.
The Sentry SDK can opt in to the new interface via Rails.error.subscribe(subscriber), where subscriber is an object implementing a report method. report takes a positional exception argument and handled: and context: keyword arguments.
report(Exception, handled: Boolean, context: Hash)
Supporting the new interface will allow Sentry users to use the standard Rails.error.{handle,record,report} methods. And in the future, when the standard interface is more widely deployed, it’ll make it easier for Rails users to try and adopt Sentry.
Rails 7.0 will add a standard interface for reporting errors to error tracking services like Sentry (rails/rails#43625).
Additionally, Rails’s internal execution wrappers have been updated to report errors via
Rails.error.report.The Sentry SDK can opt in to the new interface via
Rails.error.subscribe(subscriber), wheresubscriberis an object implementing areportmethod.reporttakes a positional exception argument andhandled:andcontext:keyword arguments.Supporting the new interface will allow Sentry users to use the standard
Rails.error.{handle,record,report}methods. And in the future, when the standard interface is more widely deployed, it’ll make it easier for Rails users to try and adopt Sentry.