Skip to content

Commit a8094be

Browse files
authored
Revert "[rails] support string errors in error reporter (#2464)" (#2533)
* Revert "[rails] support string errors in error reporter (#2464)" This reverts commit b31f0f3. * Update CHANGELOG
1 parent 9a83d6e commit a8094be

File tree

3 files changed

+2
-40
lines changed

3 files changed

+2
-40
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Bug Fixes
44

55
- Fix handling of cron with tz in Cron::Job ([#2530](https://github.com/getsentry/sentry-ruby/pull/2530))
6+
- Revert "[rails] support string errors in error reporter (#2464)" ([#2533](https://github.com/getsentry/sentry-ruby/pull/2533))
67

78
## 5.22.3
89

sentry-rails/lib/sentry/rails/error_subscriber.rb

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,7 @@ def report(error, handled:, severity:, context:, source: nil)
2727
hint.merge!(context.delete(:hint))
2828
end
2929

30-
options = { level: severity, contexts: { "rails.error" => context }, tags: tags, hint: hint }
31-
32-
case error
33-
when String
34-
Sentry::Rails.capture_message(error, **options)
35-
when Exception
36-
Sentry::Rails.capture_exception(error, **options)
37-
else
38-
log_debug("Expected an Exception or a String, got: #{error.inspect}")
39-
end
40-
end
41-
42-
def log_debug(message)
43-
Sentry.configuration.logger.debug(message)
30+
Sentry::Rails.capture_exception(error, level: severity, contexts: { "rails.error" => context }, tags: tags, hint: hint)
4431
end
4532
end
4633
end

sentry-rails/spec/sentry/rails_spec.rb

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -366,32 +366,6 @@ def capture_in_separate_process(exit_code:)
366366

367367
expect(transport.events.count).to eq(0)
368368
end
369-
370-
it "captures string messages through error reporter" do
371-
Rails.error.report("Test message", severity: :info, handled: true, context: { foo: "bar" })
372-
373-
expect(transport.events.count).to eq(1)
374-
event = transport.events.first
375-
376-
expect(event.message).to eq("Test message")
377-
expect(event.level).to eq(:info)
378-
expect(event.contexts).to include({ "rails.error" => { foo: "bar" } })
379-
expect(event.tags).to include({ handled: true })
380-
end
381-
382-
it "skips non-string and non-exception errors" do
383-
expect {
384-
Sentry.init do |config|
385-
config.logger = Logger.new($stdout)
386-
end
387-
388-
Sentry.logger.debug("Expected an Exception or a String, got: #{312.inspect}")
389-
390-
Rails.error.report(312, severity: :info, handled: true, context: { foo: "bar" })
391-
}.to output(/Expected an Exception or a String, got: 312/).to_stdout
392-
393-
expect(transport.events.count).to eq(0)
394-
end
395369
end
396370
end
397371
end

0 commit comments

Comments
 (0)