From 087b8b0b2b02a0dac64af7398fc9d99bf59f877d Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Thu, 2 Jun 2011 17:34:06 +0200 Subject: [PATCH] Pass a transaction instance as the first argument of Predis\Transaction\AbortedMultiExecException. --- lib/Predis/Transaction/AbortedMultiExecException.php | 11 ++++++++++- lib/Predis/Transaction/MultiExecContext.php | 5 ++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/Predis/Transaction/AbortedMultiExecException.php b/lib/Predis/Transaction/AbortedMultiExecException.php index acfc58a2..6da356d1 100644 --- a/lib/Predis/Transaction/AbortedMultiExecException.php +++ b/lib/Predis/Transaction/AbortedMultiExecException.php @@ -5,5 +5,14 @@ namespace Predis\Transaction; use Predis\PredisException; class AbortedMultiExecException extends PredisException { - // Aborted MULTI/EXEC transactions + private $_transaction; + + public function __construct(MultiExecContext $transaction, $message, $code = null) { + $this->_transaction = $transaction; + parent::__construct($message, $code); + } + + public function getTransaction() { + return $this->_transaction; + } } diff --git a/lib/Predis/Transaction/MultiExecContext.php b/lib/Predis/Transaction/MultiExecContext.php index 1e7c7ee7..8a6883ff 100644 --- a/lib/Predis/Transaction/MultiExecContext.php +++ b/lib/Predis/Transaction/MultiExecContext.php @@ -194,9 +194,8 @@ class MultiExecContext { $reply = $this->_client->exec(); if ($reply === null) { if ($attemptsLeft === 0) { - throw new AbortedMultiExecException( - 'The current transaction has been aborted by the server' - ); + $message = 'The current transaction has been aborted by the server'; + throw new AbortedMultiExecException($this, $message); } $this->reset(); if (isset($this->_options['on_retry']) && is_callable($this->_options['on_retry'])) {