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

Allow overriding an event's unhandled flag #698

Merged
merged 2 commits into from
Sep 22, 2021

Conversation

imjoehaines
Copy link
Contributor

Goal

This PR allows overriding an event's unhandled flag, for example to mark a handled error as unhandled within a notify block:

Bugsnag.notify(some_error) do |event|
  event.unhandled = true
end

The inverse also works — unhandled events can be marked as handled:

Bugsnag.add_on_error(proc do |event|
  event.unhandled = false

  # it may also make sense to modify the severity as well
  event.severity = "warning"
end)

This will also update the associated session (if there is one) to ensure the count of handled/unhandled events remains consistent. This happens when the unhandled flag is written to, e.g.

Bugsnag.notify(BugsnagTestException.new("It crashed")) do |event|
  expect(event.session[:events]).to eq({ handled: 1, unhandled: 0 })

  report.unhandled = true

  expect(event.session[:events]).to eq({ handled: 0, unhandled: 1 })
end

@imjoehaines imjoehaines merged commit dc40149 into next Sep 22, 2021
@imjoehaines imjoehaines deleted the allow-unhandled-override branch September 22, 2021 09:15
@imjoehaines imjoehaines mentioned this pull request Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants