From 131a5a4ef9aa9628bbd107f3885da037f27a6610 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Sat, 21 Dec 2013 11:08:29 +0100 Subject: [PATCH] Fix a few exceptions. --- lib/Predis/Connection/Factory.php | 3 ++- lib/Predis/Response/Iterator/MultiBulkTuple.php | 4 ++-- lib/Predis/Transaction/MultiExec.php | 2 +- tests/Predis/Response/Iterator/MultiBulkTupleTest.php | 2 +- tests/Predis/Transaction/MultiExecTest.php | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/Predis/Connection/Factory.php b/lib/Predis/Connection/Factory.php index 942cb760..047c26b5 100644 --- a/lib/Predis/Connection/Factory.php +++ b/lib/Predis/Connection/Factory.php @@ -12,6 +12,7 @@ namespace Predis\Connection; use InvalidArgumentException; +use UnexpectedValueException; use ReflectionClass; use Predis\Command\RawCommand; @@ -94,7 +95,7 @@ class Factory implements FactoryInterface } if (!$connection instanceof SingleConnectionInterface) { - throw new InvalidArgumentException( + throw new UnexpectedValueException( "Objects returned by connection initializers must implement ". "'Predis\Connection\SingleConnectionInterface'." ); diff --git a/lib/Predis/Response/Iterator/MultiBulkTuple.php b/lib/Predis/Response/Iterator/MultiBulkTuple.php index 715773a0..42bcbc93 100644 --- a/lib/Predis/Response/Iterator/MultiBulkTuple.php +++ b/lib/Predis/Response/Iterator/MultiBulkTuple.php @@ -12,7 +12,7 @@ namespace Predis\Response\Iterator; use OuterIterator; -use RuntimeException; +use InvalidArgumentException; use UnexpectedValueException; /** @@ -49,7 +49,7 @@ class MultiBulkTuple extends MultiBulk implements OuterIterator protected function checkPreconditions(MultiBulk $iterator) { if ($iterator->getPosition() !== 0) { - throw new RuntimeException( + throw new InvalidArgumentException( 'Cannot initialize a tuple iterator using an already initiated iterator.' ); } diff --git a/lib/Predis/Transaction/MultiExec.php b/lib/Predis/Transaction/MultiExec.php index f8049160..242b2704 100644 --- a/lib/Predis/Transaction/MultiExec.php +++ b/lib/Predis/Transaction/MultiExec.php @@ -318,7 +318,7 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface } elseif ($this->attempts) { $this->discard(); - throw new InvalidArgumentException( + throw new ClientException( 'Automatic retries are supported only when a callable block is provided.' ); } diff --git a/tests/Predis/Response/Iterator/MultiBulkTupleTest.php b/tests/Predis/Response/Iterator/MultiBulkTupleTest.php index 68fe1530..6780bb22 100644 --- a/tests/Predis/Response/Iterator/MultiBulkTupleTest.php +++ b/tests/Predis/Response/Iterator/MultiBulkTupleTest.php @@ -23,7 +23,7 @@ class MultiBulkTupleTest extends PredisTestCase { /** * @group disconnected - * @expectedException RuntimeException + * @expectedException InvalidArgumentException * @expectedExceptionMessage Cannot initialize a tuple iterator using an already initiated iterator. */ public function testInitiatedMultiBulkIteratorsAreNotValid() diff --git a/tests/Predis/Transaction/MultiExecTest.php b/tests/Predis/Transaction/MultiExecTest.php index dcf37ad2..87ca2a3e 100644 --- a/tests/Predis/Transaction/MultiExecTest.php +++ b/tests/Predis/Transaction/MultiExecTest.php @@ -368,7 +368,7 @@ class MultiExecTest extends PredisTestCase /** * @group disconnected - * @expectedException InvalidArgumentException + * @expectedException Predis\ClientException * @expectedExceptionMessage Automatic retries are supported only when a callable block is provided. */ public function testThrowsExceptionOnAutomaticRetriesWithFluentInterface()