Skip to content
Merged
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Current

concurrent-ruby-edge:

* (#659) Edge promises fail during error handling

## Release v1.0.5, edge v0.3.1 (26 Feb 2017)

concurrent-ruby:
Expand Down
4 changes: 2 additions & 2 deletions lib/concurrent/edge/promises.rb
Original file line number Diff line number Diff line change
Expand Up @@ -982,12 +982,12 @@ def value!(timeout = nil)
# @return [Exception]
def exception(*args)
raise Concurrent::Error, 'it is not rejected' unless rejected?
reason = Array(internal_state.reason).compact
reason = Array(internal_state.reason).flatten.compact
if reason.size > 1
Concurrent::MultipleErrors.new reason
else
ex = reason[0].exception(*args)
ex.set_backtrace ex.backtrace + caller
ex.set_backtrace Array(ex.backtrace) + caller
ex
end
end
Expand Down
14 changes: 13 additions & 1 deletion spec/concurrent/edge/promises_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,14 @@ def behaves_as_delay(delay, value)
let(:a_future) { future { raise 'error' } }

it 'raises a concurrent error' do
expect { zip(a_future).value! }.to raise_error(StandardError)
expect { zip(a_future).value! }.to raise_error(StandardError, 'error')
end

context 'when deeply nested' do
it 'raises the original error' do
expect { zip(zip(a_future)).value! }.to raise_error(StandardError, 'error')
end
end
end
end

Expand All @@ -242,6 +247,13 @@ def behaves_as_delay(delay, value)
end
end

describe '.rejected_future' do
it 'raises the correct error when passed an unraised error' do
f = rejected_future(StandardError.new('boom'))
expect { f.value! }.to raise_error(StandardError, 'boom')
end
end

describe 'Future' do
it 'has sync and async callbacks' do
callbacks_tester = ->(event_or_future) do
Expand Down