Skip to content

Commit 86fca8a

Browse files
authored
Client: log query on exception then rethrow it (#1920)
If an Elastica exception was thrown upon request, then make the request visible that caused it (on verbose console or in your logs), then rethrow the exception.
1 parent 40467ce commit 86fca8a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Elastica/Client.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Elastica\Client as BaseClient;
1515
use Elastica\Exception\ClientException;
16+
use Elastica\Exception\ExceptionInterface;
1617
use Elastica\Index as BaseIndex;
1718
use Elastica\Request;
1819
use Elastica\Response;
@@ -58,7 +59,13 @@ public function request(string $path, string $method = Request::GET, $data = [],
5859
$this->stopwatch->start('es_request', 'fos_elastica');
5960
}
6061

61-
$response = parent::request($path, $method, $data, $query, $contentType);
62+
try {
63+
$response = parent::request($path, $method, $data, $query, $contentType);
64+
} catch (ExceptionInterface $e) {
65+
$this->logQuery($path, $method, $data, $query, 0, 0, 0);
66+
throw $e;
67+
}
68+
6269
$responseData = $response->getData();
6370

6471
$transportInfo = $response->getTransferInfo();

0 commit comments

Comments
 (0)