Skip to content

Commit 61c581f

Browse files
committed
Merge pull request #41 from daniellienert/bugfix-exceptionrendering1
BUGFIX: Fix exception rendering on failed request If a request to elasticsearch fails, for example in case of a missing request, the error part of the ES response array is set as the exception message which is then tried to be rendered as part of the message and raises an exception due to array string conversion.
2 parents ce9f632 + 5156d94 commit 61c581f

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

Classes/Flowpack/ElasticSearch/Transfer/Exception.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct($message, $code, \TYPO3\Flow\Http\Response $response
3434
$this->response = $response;
3535
$this->request = $request;
3636
if ($request !== null) {
37-
$message = sprintf("[%s %s]: %s\n\nRequest data: %s",
37+
$message = sprintf("Elasticsearch request failed.\n[%s %s]: %s\n\nRequest data: %s",
3838
$request->getMethod(),
3939
$request->getUri(),
4040
$message . '; Response body: ' . $response->getContent(),

Classes/Flowpack/ElasticSearch/Transfer/Response.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public function __construct(\TYPO3\Flow\Http\Response $response, \TYPO3\Flow\Htt
4747
}
4848

4949
if (array_key_exists('error', $treatedContent)) {
50-
throw new Exception\ApiException($treatedContent['error'], 1338977435, $response, $request);
50+
$exceptionMessage = print_r($treatedContent['error'], true);
51+
throw new Exception\ApiException($exceptionMessage, 1338977435, $response, $request);
5152
}
5253
}
5354

Tests/Functional/Fixtures/TweetRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
/**
1818
* @Flow\Scope("singleton")
1919
*/
20-
class TweetRepository extends \TYPO3\Flow\Persistence\Repository
20+
class TweetRepository extends \TYPO3\Flow\Persistence\Repository
2121
{
2222
}

0 commit comments

Comments
 (0)