Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion lib/dry/monads/do.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Do
extend Mixin

# @api private
class Halt < StandardError
class Halt < Exception
# @api private
attr_reader :result

Expand Down
23 changes: 22 additions & 1 deletion spec/integration/do_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def call

def transaction
yield
rescue => e
rescue Exception => e
@rolled_back = true
raise e
end
Expand All @@ -118,6 +118,27 @@ def transaction
expect(instance.rolled_back).to be(true)
end
end

context 'with rescue block in method' do
before do
klass.class_eval do
def call(m1)
yield m1
raise "oops"
rescue => e
Failure("handled exception: #{e}")
end
end
end

it 'catches standard exception' do
expect(instance.call(Success(1))).to eql(Failure("handled exception: oops"))
end

it 'does not catch Halt exception' do
expect(instance.call(Failure(5))).to eql(Failure(5))
end
end
end

context 'with Maybe' do
Expand Down