Skip to content

Commit

Permalink
Merge pull request #127 from lozynskiadam/handle-request-timeout-status
Browse files Browse the repository at this point in the history
Handling responses with request timeout status
  • Loading branch information
maciejlew authored Jan 9, 2024
2 parents b01e39e + 7ddf1b6 commit cf2c120
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Infrastructure/ResponseHttpCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ class ResponseHttpCode
const CREATED = 201;
const ACCEPTED = 202;
const NO_CONTENT = 204;
const REQUEST_TIMEOUT = 408;
const SERVICE_UNAVAILABLE = 503;
}
2 changes: 2 additions & 0 deletions src/Infrastructure/ResponseMapper/RestResponseMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public function map(ResponseInterface $response): stdClass
return new stdClass();
} elseif ($statusCode == ResponseHttpCode::SERVICE_UNAVAILABLE) {
throw ApiErrorException::withMessageAndStatusCode('Service unavailable', $statusCode);
} elseif ($statusCode == ResponseHttpCode::REQUEST_TIMEOUT) {
throw ApiErrorException::withMessageAndStatusCode('Request timed out', $statusCode);
} elseif ($contents) {
$object = $this->jsonDecode->decode($contents);

Expand Down

0 comments on commit cf2c120

Please sign in to comment.