Skip to content

Commit

Permalink
VAN-954 service.amadeus / Warning: DOMDocument::loadXML(): Empty stri…
Browse files Browse the repository at this point in the history
…ng supplied as input
  • Loading branch information
FriedemannSchmuhl committed Apr 9, 2018
1 parent d28223c commit bef0e0c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
2 changes: 0 additions & 2 deletions config/development.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ debug:
log_ama_traffic: true
pimpledump:
enabled: true
throwup:
enabled: true
remarks:
log_ama_traffic: true
pimpledump:
Expand Down
2 changes: 0 additions & 2 deletions config/production.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ debug:
log_ama_traffic: false
pimpledump:
enabled: true
throwup:
enabled: true
remarks:
log_ama_traffic: false
pimpledump:
Expand Down
2 changes: 0 additions & 2 deletions config/staging.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ debug:
log_ama_traffic: false
pimpledump:
enabled: true
throwup:
enabled: true
remarks:
log_ama_traffic: false
pimpledump:
Expand Down
3 changes: 2 additions & 1 deletion src/Application/Provider/ErrorProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public function register(Container $app): void
'monolog.level' => Logger::NOTICE,
'monolog.formatter' => function () {
return new JsonFormatter();
}
},
'monolog.use_error_handler' => false
]
);

Expand Down
27 changes: 25 additions & 2 deletions src/Search/Model/AmadeusClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function __construct(
*
* @return SearchResponse
* @throws AmadeusRequestException
* @throws \Exception
*/
public function search(Request $request, BusinessCase $businessCase) : SearchResponse
{
Expand All @@ -79,7 +80,14 @@ public function search(Request $request, BusinessCase $businessCase) : SearchRes

$requestOptions = $this->requestTransformer->buildFareMasterRequestOptions($request);

$result = $client->fareMasterPricerTravelBoardSearch($requestOptions);
try {
$result = $client->fareMasterPricerTravelBoardSearch($requestOptions);
} catch (\Exception $exception) {
if ($this->isEmptyResponseError($exception)) {
return $this->responseTransformer->createEmptyResponse();
}
throw $exception;
}

if ($this->isEmptyResultError($result)) {
// @TODO [ts] - MID - create a metric do track these behavior
Expand Down Expand Up @@ -116,4 +124,19 @@ private function isEmptyResultError(Client\Result $result)
&& isset($result->messages[0])
&& in_array($result->messages[0]->code, self::EMPTY_RESULT_ERRORS);
}
}

/**
* Does the error indicate that the response was empty?
*
* @param \Exception $exception
* @return bool
*/
private function isEmptyResponseError(\Exception $exception): bool
{
if ('Warning: DOMDocument::loadXML(): Empty string supplied as input' === $exception->getMessage()) {
return true;
}

return false;
}
}

0 comments on commit bef0e0c

Please sign in to comment.