Skip to content

Commit

Permalink
reworks some of the error classes a bit and ensures we still raise wh…
Browse files Browse the repository at this point in the history
…en not stopping rollbacks on failure
  • Loading branch information
markrebec committed May 27, 2015
1 parent e0ec801 commit 3b73436
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 16 additions & 1 deletion lib/transactor/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ def initialize(e, performance=nil)
end
end

class RollbacksBombed < StandardError
attr_reader :performances

def initialize(performances)
super("Performance rollback failed!")
@performances = performances
end
end

class RollbackBombed < PerformanceBombed; end

class TransactionError < StandardError
Expand All @@ -26,5 +35,11 @@ def initialize(e, transaction)
end

class TransactionFailed < TransactionError; end
class RollbackFailed < TransactionError; end

class RollbackFailed < TransactionError
def initialize(transaction)
super("Transaction rollback failed!")
@transaction = transaction
end
end
end
4 changes: 3 additions & 1 deletion lib/transactor/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def in_transaction(*args, &block)
begin
rollback
rescue Exception => e # yes, here too
raise RollbackFailed.new(e, self)
raise RollbackFailed.new(self)
end

raise TransactionFailed.new(e, self)
Expand Down Expand Up @@ -56,6 +56,8 @@ def rollback_performances
raise RollbackBombed.new(e, performance) if Transactor.configuration.stop_rollback_on_failure
end
end

raise RollbacksBombed.new(bombed_rollbacks) if Transactor.configuration.stop_rollback_on_failure && !bombed_rollbacks.empty?
end

def performances
Expand Down

0 comments on commit 3b73436

Please sign in to comment.