Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3 Branch Pick] Add some error context in transport_failure_callback #1003

Merged
merged 1 commit into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ end
If Raven fails to send an event to Sentry for any reason (either the Sentry server has returned a 4XX or 5XX response), this Proc or lambda will be called.

```ruby
config.transport_failure_callback = lambda { |event|
AdminMailer.email_admins("Oh god, it's on fire!", event).deliver_later
config.transport_failure_callback = lambda { |event, error|
AdminMailer.email_admins("Oh god, it's on fire because #{error.message}!", event).deliver_later
}
```

Expand Down
2 changes: 1 addition & 1 deletion lib/raven/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def failed_send(e, event)
configuration.logger.warn("Failed to submit event: #{get_log_message(event)}")

# configuration.transport_failure_callback can be false & nil
configuration.transport_failure_callback.call(event) if configuration.transport_failure_callback # rubocop:disable Style/SafeNavigation
configuration.transport_failure_callback.call(event, e) if configuration.transport_failure_callback # rubocop:disable Style/SafeNavigation
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/raven/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
end

it "transport failure should call transport_failure_callback" do
@instance.configuration.transport_failure_callback = proc { |_e| @io.puts "OK!" }
@instance.configuration.transport_failure_callback = proc { |_event, error| @io.puts "OK! - #{error.message}" }

expect(@instance.client.transport).to receive(:send_event).exactly(1).times.and_raise(Faraday::ConnectionFailed, "conn failed")
@instance.capture_exception(build_exception)
expect(@io.string).to match(/OK!$/)
expect(@io.string).to match(/OK! - conn failed$/)
end

describe '#before_send' do
Expand Down