Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client: log query on exception then rethrow it #1920

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Elastica/Client.php
Expand Up @@ -13,6 +13,7 @@

use Elastica\Client as BaseClient;
use Elastica\Exception\ClientException;
use Elastica\Exception\ExceptionInterface;
use Elastica\Index as BaseIndex;
use Elastica\Request;
use Elastica\Response;
Expand Down Expand Up @@ -58,7 +59,13 @@ public function request(string $path, string $method = Request::GET, $data = [],
$this->stopwatch->start('es_request', 'fos_elastica');
}

$response = parent::request($path, $method, $data, $query, $contentType);
try {
$response = parent::request($path, $method, $data, $query, $contentType);
} catch (ExceptionInterface $e) {
$this->logQuery($path, $method, $data, $query, 0, 0, 0);
throw $e;
}

$responseData = $response->getData();

$transportInfo = $response->getTransferInfo();
Expand Down