Skip to content

Commit

Permalink
add elastica exception
Browse files Browse the repository at this point in the history
  • Loading branch information
chabior committed Aug 7, 2014
1 parent ccdea91 commit 93ef291
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/Elastica/Connection/ConnectionPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ConnectionPool
/**
* @param array $connections
* @param \Elastica\Connection\Strategy\StrategyInterface $strategy
* @param type $callback
* @param callback $callback
*/
public function __construct(array $connections, StrategyInterface $strategy, $callback = null)
{
Expand Down Expand Up @@ -89,6 +89,7 @@ public function getConnections()

/**
* @return \Elastica\Connection
* @throws \Elastica\Exception\ClientException
*/
public function getConnection()
{
Expand All @@ -97,7 +98,7 @@ public function getConnection()

/**
* @param \Elastica\Connection $connection
* @param Exception $e
* @param \Exception $e
* @param Client $client
*/
public function onFail(Connection $connection, Exception $e, Client $client)
Expand Down
6 changes: 4 additions & 2 deletions lib/Elastica/Connection/Strategy/CallbackStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Elastica\Connection\Strategy;

use Elastica\Exception\InvalidException;

/**
* Description of CallbackStrategy
*
Expand All @@ -17,12 +19,12 @@ class CallbackStrategy implements StrategyInterface

/**
* @param Closure $callback
* @throws \InvalidArgumentException
* @throws \Elastica\Exception\InvalidException
*/
public function __construct($callback)
{
if (!self::isValid($callback)) {
throw new \InvalidArgumentException(sprintf('Callback should be a Closure, %s given!', gettype($callback)));
throw new InvalidException(sprintf('Callback should be a Closure, %s given!', gettype($callback)));
}

$this->_callback = $callback;
Expand Down
1 change: 1 addition & 0 deletions lib/Elastica/Connection/Strategy/RoundRobin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class RoundRobin extends Simple
/**
* @param array|\Elastica\Connection[] $connections
* @return \Elastica\Connection
* @throws \Elastica\Exception\ClientException
*/
public function getConnection($connections)
{
Expand Down
2 changes: 2 additions & 0 deletions lib/Elastica/Connection/Strategy/Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Elastica\Connection\Strategy;

use Elastica\Connection\Strategy\StrategyInterface;
use Elastica\Exception\ClientException;

/**
* Description of SimpleStrategy
Expand All @@ -15,6 +16,7 @@ class Simple implements StrategyInterface
/**
* @param array|\Elastica\Connection[] $connections
* @return \Elastica\Connection
* @throws \Elastica\Exception\ClientException
*/
public function getConnection($connections)
{
Expand Down
6 changes: 4 additions & 2 deletions lib/Elastica/Connection/Strategy/StrategyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Elastica\Connection\Strategy;

use Elastica\Exception\InvalidException;

/**
* Description of StrategyFactory
*
Expand All @@ -12,7 +14,7 @@ class StrategyFactory
/**
* @param mixed|Closure|String|StrategyInterface $strategyName
* @return \Elastica\Connection\Strategy\StrategyInterface
* @throws \InvalidArgumentException
* @throws \Elastica\Exception\InvalidException
*/
public static function create($strategyName)
{
Expand All @@ -31,7 +33,7 @@ public static function create($strategyName)
}

if (!$strategy instanceof StrategyInterface) {
throw new \InvalidArgumentException('Can\'t load strategy class');
throw new InvalidException('Can\'t load strategy class');
}

return $strategy;
Expand Down

0 comments on commit 93ef291

Please sign in to comment.