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

Add SignalException to default ignore_classes #479

Merged
merged 4 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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