Skip to content

Commit

Permalink
Add SignalException to default ignore_classes
Browse files Browse the repository at this point in the history
With #397 we receive SignalException error reports when puma shuts down,
which aren't really errors.
  • Loading branch information
tobyhs committed Aug 1, 2018
1 parent f832296 commit 44b79e1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
6 changes: 3 additions & 3 deletions lib/bugsnag/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def initialize
self.auto_capture_sessions = false
self.session_endpoint = DEFAULT_SESSION_ENDPOINT

# SystemExit and Interrupt are common Exception types seen with successful
# exits and are not automatically reported to Bugsnag
self.ignore_classes = Set.new([SystemExit, Interrupt])
# SystemExit and SignalException are common Exception types seen with
# successful exits and are not automatically reported to Bugsnag
self.ignore_classes = Set.new([SystemExit, SignalException])

# Read the API key from the environment
self.api_key = ENV["BUGSNAG_API_KEY"]
Expand Down
2 changes: 1 addition & 1 deletion spec/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def debug(name, &block)
end

it "should have exit exception classes ignored by default" do
expect(subject.ignore_classes).to eq(Set.new([SystemExit, Interrupt]))
expect(subject.ignore_classes).to eq(Set.new([SystemExit, SignalException]))
end

end
39 changes: 24 additions & 15 deletions spec/report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,27 @@ def gloops
end

it "sets correct severity and reason for specific error classes" do
Bugsnag.notify(SignalException.new("TERM"))
expect(Bugsnag).to have_sent_notification{ |payload, headers|
event = get_event_from_payload(payload)
expect(event["unhandled"]).to be false
expect(event["severity"]).to eq("info")
expect(event["severityReason"]).to eq({
"type" => "errorClass",
"attributes" => {
"errorClass" => "SignalException"
}
})
}
original_ignore_classes = Bugsnag.configuration.ignore_classes

begin
# The default ignore_classes includes SignalException, so we need to
# temporarily set it to something else.
Bugsnag.configuration.ignore_classes = Set[SystemExit]
Bugsnag.notify(SignalException.new("TERM"))
expect(Bugsnag).to have_sent_notification{ |payload, headers|
event = get_event_from_payload(payload)
expect(event["unhandled"]).to be false
expect(event["severity"]).to eq("info")
expect(event["severityReason"]).to eq({
"type" => "errorClass",
"attributes" => {
"errorClass" => "SignalException"
}
})
}
ensure
Bugsnag.configuration.ignore_classes = original_ignore_classes
end
end

# TODO: nested context
Expand Down Expand Up @@ -1052,10 +1061,10 @@ def gloops
expect(exception["message"]).to eq("'nil' was notified as an exception")

stacktrace = exception["stacktrace"][0]
expect(stacktrace["lineNumber"]).to eq(1047)
expect(stacktrace["lineNumber"]).to eq(1056)
expect(stacktrace["file"]).to end_with("spec/report_spec.rb")
expect(stacktrace["code"]["1046"]).to eq(" it 'uses an appropriate message if nil is notified' do")
expect(stacktrace["code"]["1047"]).to eq(" Bugsnag.notify(nil)")
expect(stacktrace["code"]["1055"]).to eq(" it 'uses an appropriate message if nil is notified' do")
expect(stacktrace["code"]["1056"]).to eq(" Bugsnag.notify(nil)")
}
end

Expand Down

0 comments on commit 44b79e1

Please sign in to comment.