diff --git a/src/Elasticsearch/Transport.php b/src/Elasticsearch/Transport.php index 96b4e3ec2..a77160c6d 100644 --- a/src/Elasticsearch/Transport.php +++ b/src/Elasticsearch/Transport.php @@ -10,6 +10,7 @@ use Elasticsearch\Connections\ConnectionInterface; use GuzzleHttp\Ring\Future\FutureArrayInterface; use Psr\Log\LoggerInterface; +use Throwable; /** * Class Transport @@ -119,9 +120,9 @@ function ($response) { // Note, this could be a 4xx or 5xx error }, //onFailure - function ($response) { + function (Throwable $response) { // Ignore 400 level errors, as that means the server responded just fine - if (!(isset($response['code']) && $response['code'] >=400 && $response['code'] < 500)) { + if ($response->getCode() < 400 || $response->getCode() >= 500) { // Otherwise schedule a check $this->connectionPool->scheduleCheck(); }