Skip to content

Commit 59c8b1e

Browse files
David Abdemoulaiepitr-ch
authored andcommitted
Concurrent::Edge::AbstractPromise now rescues Exception
1 parent 10ceb96 commit 59c8b1e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/concurrent/edge/future.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,8 +925,11 @@ def complete_with(new_state, raise_on_reassign = true)
925925
# @return [Future]
926926
def evaluate_to(*args, block)
927927
complete_with Future::Success.new(block.call(*args))
928-
rescue => error
928+
rescue StandardError => error
929929
complete_with Future::Failed.new(error)
930+
rescue Exception => error
931+
complete_with Future::Failed.new(error)
932+
raise error
930933
end
931934
end
932935

spec/concurrent/edge/future_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,14 @@
334334
expect(f.reason).to be_an_instance_of TypeError
335335
end
336336
end
337+
338+
it 'completes future when Exception raised' do
339+
f = Concurrent.future { raise Exception, 'fail' }
340+
sleep 0.2
341+
expect(f).to be_completed
342+
expect(f).to be_failed
343+
expect{ f.value! }.to raise_error(Exception, 'fail')
344+
end
337345
end
338346

339347
describe 'interoperability' do

0 commit comments

Comments
 (0)