lib/sentry/rails/rescued_exception_interceptor.rb in sentry-rails-5.21.0 vs lib/sentry/rails/rescued_exception_interceptor.rb in sentry-rails-5.22.0
- old
+ new
@@ -17,10 +17,19 @@
raise e
end
end
def report_rescued_exceptions?
- Sentry.configuration.rails.report_rescued_exceptions
+ # In rare edge cases, `Sentry.configuration` might be `nil` here.
+ # Hence, we use a safe navigation and fallback to a reasonable default
+ # of `true` in case the configuration couldn't be loaded.
+ # See https://github.com/getsentry/sentry-ruby/issues/2386
+ report_rescued_exceptions = Sentry.configuration&.rails&.report_rescued_exceptions
+ return report_rescued_exceptions unless report_rescued_exceptions.nil?
+
+ # `true` is the default for `report_rescued_exceptions`, as specified in
+ # `sentry-rails/lib/sentry/rails/configuration.rb`.
+ true
end
end
end
end