Skip to content

Commit bee677d

Browse files
committed
TVar: better abort exception.
1 parent 0ccc44b commit bee677d

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

lib/concurrent/tvar.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ def self.current=(transaction)
8787

8888
end
8989

90-
class AbortException < Exception
91-
end
90+
AbortError = Class.new(StandardError)
9291

9392
def atomically
9493
raise ArgumentError.new('no block given') unless block_given?
@@ -116,7 +115,7 @@ def atomically
116115

117116
begin
118117
result = yield
119-
rescue AbortException => e
118+
rescue AbortError => e
120119
transaction.abort
121120
result = ABORTED
122121
rescue => e
@@ -144,7 +143,7 @@ def atomically
144143
end
145144

146145
def abort_transaction
147-
raise AbortException.new
146+
raise AbortError.new
148147
end
149148

150149
module_function :atomically, :abort_transaction

spec/concurrent/tvar_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ module Concurrent
129129
describe '#abort_transaction' do
130130

131131
it 'raises an exception outside an #atomically block' do
132-
expect { Concurrent::abort_transaction }.to raise_error(Concurrent::AbortException)
132+
expect { Concurrent::abort_transaction }.to raise_error(Concurrent::AbortError)
133133
end
134134

135135
end

0 commit comments

Comments
 (0)