File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -958,7 +958,9 @@ def exception(*args)
958
958
raise Concurrent ::Error , 'it is not rejected' unless rejected?
959
959
reason = Array ( internal_state . reason ) . flatten . compact
960
960
if reason . size > 1
961
- Concurrent ::MultipleErrors . new reason
961
+ ex = Concurrent ::MultipleErrors . new reason
962
+ ex . set_backtrace ( caller )
963
+ ex
962
964
else
963
965
ex = reason [ 0 ] . clone . exception ( *args )
964
966
ex . set_backtrace Array ( ex . backtrace ) + caller
Original file line number Diff line number Diff line change @@ -468,6 +468,25 @@ def behaves_as_delay(delay, value)
468
468
end
469
469
expect ( future ( 0 , &body ) . run . reason . message ) . to eq '5'
470
470
end
471
+
472
+ it 'can be risen when rejected' do
473
+ future = rejected_future TypeError . new
474
+ backtrace = caller ; exception = raise future rescue $!
475
+ expect ( exception ) . to be_a TypeError
476
+ expect ( exception . backtrace [ 2 ..-1 ] ) . to eq backtrace
477
+
478
+ exception = TypeError . new
479
+ exception . set_backtrace ( first_backtrace = %W[ /a /b /c ] )
480
+ future = rejected_future exception
481
+ backtrace = caller ; exception = raise future rescue $!
482
+ expect ( exception ) . to be_a TypeError
483
+ expect ( exception . backtrace - exception . backtrace [ 3 ..4 ] ) . to eq ( first_backtrace + backtrace )
484
+
485
+ future = rejected_future ( TypeError . new ) & rejected_future ( TypeError . new )
486
+ backtrace = caller ; exception = raise future rescue $!
487
+ expect ( exception ) . to be_a Concurrent ::MultipleErrors
488
+ expect ( exception . backtrace [ 2 ..-1 ] ) . to eq backtrace
489
+ end
471
490
end
472
491
473
492
describe 'interoperability' do
You can’t perform that action at this time.
0 commit comments