-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ErrorHandler#harshly no longer fails when backtrace nil
- Loading branch information
Raph Estrada
committed
Mar 8, 2019
1 parent
01195ef
commit ddd2424
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'spec_helper' | ||
require 'time' | ||
|
||
describe Makara::ErrorHandler do | ||
let(:handler){ described_class.new } | ||
|
||
before{ allow(::Makara::Logging::Logger).to receive(:log) } | ||
|
||
describe "#harshly" do | ||
subject{ handler.send(:harshly, error) } | ||
|
||
context "an error with a backtrace" do | ||
let(:error){ StandardError.new } | ||
|
||
before do | ||
error.set_backtrace(caller) | ||
expect(error.backtrace).not_to be_nil | ||
end | ||
|
||
it "re-raises the original exception and logs with a backtrace" do | ||
expect{ subject }.to raise_error(error) | ||
expect(::Makara::Logging::Logger).to have_received(:log).with(/Harshly handling: StandardError\s+.+/i) | ||
end | ||
end | ||
|
||
context "an error without a backtrace" do | ||
let(:error){ StandardError.new } | ||
|
||
before { expect(error.backtrace).to be_nil } | ||
|
||
it "sends a metric, re-raises the original exception and logs without a backtrace " do | ||
expect{ subject }.to raise_error(error) | ||
expect(::Makara::Logging::Logger).to have_received(:log).with("Harshly handling: StandardError\n") | ||
end | ||
|
||
end | ||
end | ||
|
||
end |