Skip to content

Commit

Permalink
Handle is an application convert a php error into an Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Xon authored and colinmollenhour committed Jul 5, 2017
1 parent 6479bf8 commit 9c14b4b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,20 @@ public function connect()
if ( ! $this->redis) {
$this->redis = new Redis;
}
$socketTimeout = $this->timeout ? $this->timeout : 0.0;
$result = $this->persistent
? $this->redis->pconnect($this->host, $this->port, $socketTimeout, $this->persistent)
: $this->redis->connect($this->host, $this->port, $socketTimeout);
try
{
$socketTimeout = $this->timeout ? $this->timeout : 0.0;
$result = $this->persistent
? $this->redis->pconnect($this->host, $this->port, $socketTimeout, $this->persistent)
: $this->redis->connect($this->host, $this->port, $socketTimeout);
}
catch(Exception $e)
{
// Some applications will capture the php error that phpredis can sometimes generate and throw it as an Exception
$result = false;
$errno = 1;
$errstr = $e->getMessage();
}
}

// Use recursion for connection retries
Expand Down

0 comments on commit 9c14b4b

Please sign in to comment.