Skip to content

Commit

Permalink
Merge pull request amabnl#51 in FLIGHT/service.amadeus from VAN-954 t…
Browse files Browse the repository at this point in the history
…o master

* commit 'bef0e0ccd1bfdef783aba332e8aee8900f6ff346':
  VAN-954 service.amadeus / Warning: DOMDocument::loadXML(): Empty string supplied as input
  • Loading branch information
f-woelfing-invia committed Apr 9, 2018
2 parents d28223c + bef0e0c commit 5492a29
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 5492a29

Please sign in to comment.