Skip to content

Commit

Permalink
RescuedExceptionInterceptor: Handle empty configuration
Browse files Browse the repository at this point in the history
Previously, it could happen that `Sentry.configuration` was `nil`.
In this case, calling `rails` would produce a `NoMethodError`.
We fix this issue by using safe navigation.

Furthermore, this commit ensures we use a reasonable default
in case the configuration couldn't be loaded. Since the config
`report_rescued_exceptions` defaults to `true`, we assume
this value here, too.
 
Fixes #2386
  • Loading branch information
MrSerth authored Oct 10, 2024
1 parent 499cbac commit 83a6981
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ def call(env)
end

def report_rescued_exceptions?
Sentry.configuration.rails.report_rescued_exceptions
report_rescued_exceptions = Sentry.configuration&.rails&.report_rescued_exceptions
return report_rescued_exceptions unless report_rescued_exceptions.nil?

true
end
end
end
Expand Down

0 comments on commit 83a6981

Please sign in to comment.