Skip to content

Commit d672746

Browse files
committed
Merge pull request #152 from alexfalkowski/arf/raise-exception
Make sure we raise the exception, rather than throw it.
2 parents 8f80ce0 + 0180758 commit d672746

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/concurrent/tvar.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def atomically
112112
result = Transaction::ABORTED
113113
rescue => e
114114
transaction.abort
115-
throw e
115+
raise e
116116
end
117117
# If we can commit, break out of the loop
118118

spec/concurrent/tvar_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ module Concurrent
4040
expect { Concurrent::atomically }.to raise_error(ArgumentError)
4141
end
4242

43+
it 'raises the same exception that was raised in Concurrent::atomically' do
44+
expect {
45+
Concurrent::atomically do
46+
raise StandardError, 'This is an error!'
47+
end
48+
}.to raise_error(StandardError, 'This is an error!')
49+
end
50+
4351
it 'retries on abort' do
4452
count = 0
4553

0 commit comments

Comments
 (0)