diff --git a/lib/dm-transactions.rb b/lib/dm-transactions.rb index 57f4d05..a5a7874 100644 --- a/lib/dm-transactions.rb +++ b/lib/dm-transactions.rb @@ -129,19 +129,13 @@ def commit begin self.begin rval = within { |*block_args| yield(*block_args) } - rescue Exception => exception - if begin? - rollback - end - raise exception + commit + complete = true ensure - unless exception - if begin? - commit - end - return rval - end + rollback unless complete end + + rval else unless begin? raise "Illegal state for commit without block: #{state}"