Predis\CommunicationException::getConnection PHP Method

getConnection() public method

Gets the connection that generated the exception.
public getConnection ( ) : Predis\Connection\NodeConnectionInterface
return Predis\Connection\NodeConnectionInterface
    public function getConnection()
    {
        return $this->connection;
    }

Usage Example

 /**
  * Offers a generic and reusable method to handle exceptions generated by
  * a connection object.
  *
  * @param CommunicationException $exception Exception.
  */
 public static function handle(CommunicationException $exception)
 {
     if ($exception->shouldResetConnection()) {
         $connection = $exception->getConnection();
         if ($connection->isConnected()) {
             $connection->disconnect();
         }
     }
     throw $exception;
 }