Skip to content

Commit 747f8fa

Browse files
committed
Do not raise when Rails.error.report receives context: nil
1 parent ae51457 commit 747f8fa

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

activesupport/lib/active_support/error_reporter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def report(error, handled: true, severity: handled ? :warning : :error, context:
217217
raise ArgumentError, "severity must be one of #{SEVERITIES.map(&:inspect).join(", ")}, got: #{severity.inspect}"
218218
end
219219

220-
full_context = ActiveSupport::ExecutionContext.to_h.merge(context)
220+
full_context = ActiveSupport::ExecutionContext.to_h.merge(context || {})
221221
disabled_subscribers = ActiveSupport::IsolatedExecutionState[self]
222222
@subscribers.each do |subscriber|
223223
unless disabled_subscribers&.any? { |s| s === subscriber }

activesupport/test/error_reporter_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@ class ErrorReporterTest < ActiveSupport::TestCase
284284
assert_includes error.message, "Reported error must be an Exception"
285285
end
286286

287+
test "report accepts context as nil" do
288+
@reporter.report(@error, context: nil)
289+
assert_equal({}, @subscriber.events.last[4])
290+
end
291+
287292
test "report errors only once" do
288293
assert_difference -> { @subscriber.events.size }, +1 do
289294
@reporter.report(@error, handled: false)

0 commit comments

Comments
 (0)