Skip to content

Commit 9b3dd1d

Browse files
committed
wip
1 parent 0f3f7fb commit 9b3dd1d

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

‎src/Service/ApiService.php‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -482,15 +482,15 @@ private function buildException(string $requestUrl, ResponseInterface $response)
482482
$message = 'TheApi call "' . $requestUrl . '" failed, status code: ' . $responseCode . ' ' . $response->getReasonPhrase();
483483
$message .= $this->getErrorResponseMessage($response->getBody()->getContents());
484484

485-
if ($responseCode == 0) {
486-
return new ApiException($message, $responseCode); // network communication failure
487-
} elseif ($responseCode == 404) {
488-
return new NotFoundApiServiceException($message, $responseCode);
489-
} elseif ($responseCode >= 500) {
490-
return new ApiException($message, $responseCode); // server-side error
491-
} else {
492-
return new class ($message, $responseCode) extends \RuntimeException implements ApiServiceException {
493-
};
485+
switch (true) {
486+
case $responseCode == 404:
487+
return new NotFoundApiServiceException($message, $responseCode);
488+
case $responseCode >= 500:
489+
case $responseCode == 0: // network communication failure
490+
return new ApiException($message, $responseCode);
491+
default:
492+
return new class ($message, $responseCode) extends \RuntimeException implements ApiServiceException {
493+
};
494494
}
495495
}
496496

0 commit comments

Comments
 (0)