Skip to content

Commit a854426

Browse files
authored
Merge pull request #107 from iamvery/iamvery/errors
Make MismatchError a base Exception
2 parents 1105e41 + ad48edc commit a854426

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

lib/scientist/experiment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def self.new(name)
1818
end
1919

2020
# A mismatch, raised when raise_on_mismatches is enabled.
21-
class MismatchError < StandardError
21+
class MismatchError < Exception
2222
attr_reader :name, :result
2323

2424
def initialize(name, result)

test/scientist/experiment_test.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,20 @@ def @ex.raised(op, exception)
444444
assert_raises(Scientist::Experiment::MismatchError) { @ex.run }
445445
end
446446

447+
it "allows MismatchError to bubble up through bare rescues" do
448+
Fake.raise_on_mismatches = true
449+
@ex.use { "control" }
450+
@ex.try { "candidate" }
451+
runner = -> {
452+
begin
453+
@ex.run
454+
rescue
455+
# StandardError handled
456+
end
457+
}
458+
assert_raises(Scientist::Experiment::MismatchError) { runner.call }
459+
end
460+
447461
describe "#raise_on_mismatches?" do
448462
it "raises when there is a mismatch if the experiment instance's raise on mismatches is enabled" do
449463
Fake.raise_on_mismatches = false

0 commit comments

Comments
 (0)