1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-04 20:27:31 +02:00

Fix unhandled throwable

This commit is contained in:
Avtandil Kikabidze
2018-04-07 04:38:38 +04:00
parent 569cdd635d
commit aad9de4d0d
2 changed files with 4 additions and 2 deletions

View File

@@ -13,12 +13,12 @@ namespace Monolog\Handler;
use Elasticsearch\Client; use Elasticsearch\Client;
use Elasticsearch\Common\Exceptions\RuntimeException as ElasticSearchRuntimeException; use Elasticsearch\Common\Exceptions\RuntimeException as ElasticSearchRuntimeException;
use Exception;
use InvalidArgumentException; use InvalidArgumentException;
use Monolog\Formatter\ElasticSearchFormatter; use Monolog\Formatter\ElasticSearchFormatter;
use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\FormatterInterface;
use Monolog\Logger; use Monolog\Logger;
use RuntimeException; use RuntimeException;
use Throwable;
/** /**
* Elastic Search handler * Elastic Search handler
@@ -149,7 +149,7 @@ class ElasticSearchHandler extends AbstractProcessingHandler
if ($responses['errors'] === true) { if ($responses['errors'] === true) {
throw new ElasticSearchRuntimeException('ElasticSearch returned error for one of the records'); throw new ElasticSearchRuntimeException('ElasticSearch returned error for one of the records');
} }
} catch (Exception $e) { } catch (Throwable $e) {
if (! $this->options['ignore_error']) { if (! $this->options['ignore_error']) {
throw new RuntimeException('Error sending messages to ElasticSearch', 0, $e); throw new RuntimeException('Error sending messages to ElasticSearch', 0, $e);
} }

View File

@@ -196,7 +196,9 @@ class ElasticSearchHandlerTest extends TestCase
0 => 'bar', 0 => 'bar',
]; ];
$hosts = [['host' => '127.0.0.1', 'port' => 9200]];
$client = ClientBuilder::create() $client = ClientBuilder::create()
->setHosts($hosts)
->build(); ->build();
$handler = new ElasticSearchHandler($client, $this->options); $handler = new ElasticSearchHandler($client, $this->options);
try { try {