diff --git a/src/Monolog/Handler/ElasticSearchHandler.php b/src/Monolog/Handler/ElasticSearchHandler.php index d465438a..3df39d91 100644 --- a/src/Monolog/Handler/ElasticSearchHandler.php +++ b/src/Monolog/Handler/ElasticSearchHandler.php @@ -13,12 +13,12 @@ namespace Monolog\Handler; use Elasticsearch\Client; use Elasticsearch\Common\Exceptions\RuntimeException as ElasticSearchRuntimeException; -use Exception; use InvalidArgumentException; use Monolog\Formatter\ElasticSearchFormatter; use Monolog\Formatter\FormatterInterface; use Monolog\Logger; use RuntimeException; +use Throwable; /** * Elastic Search handler @@ -149,7 +149,7 @@ class ElasticSearchHandler extends AbstractProcessingHandler if ($responses['errors'] === true) { throw new ElasticSearchRuntimeException('ElasticSearch returned error for one of the records'); } - } catch (Exception $e) { + } catch (Throwable $e) { if (! $this->options['ignore_error']) { throw new RuntimeException('Error sending messages to ElasticSearch', 0, $e); } diff --git a/tests/Monolog/Handler/ElasticSearchHandlerTest.php b/tests/Monolog/Handler/ElasticSearchHandlerTest.php index 1045e034..e7d02297 100644 --- a/tests/Monolog/Handler/ElasticSearchHandlerTest.php +++ b/tests/Monolog/Handler/ElasticSearchHandlerTest.php @@ -196,7 +196,9 @@ class ElasticSearchHandlerTest extends TestCase 0 => 'bar', ]; + $hosts = [['host' => '127.0.0.1', 'port' => 9200]]; $client = ClientBuilder::create() + ->setHosts($hosts) ->build(); $handler = new ElasticSearchHandler($client, $this->options); try {