This commit is contained in:
Juan Pablo Vial
2025-05-19 14:02:55 -04:00
parent ce75ec1548
commit f34ed03b84
3 changed files with 28 additions and 3 deletions

View File

@ -30,11 +30,23 @@ abstract class AbstractEndPoint extends LoggerEnabled implements EndPoint
if (in_array($status, $invalidStatus)) {
$contents = $response->getBody()->getContents();
$this->logger->warning('Invalid Status', [
'uri' => $request_uri,
'code' => $status,
'reason' => $reason,
'contents' => $contents
]);
$exception = new HttpException("{$reason}\n{$contents}", $status);
throw new EmptyResponse($request_uri, $exception);
}
if (!in_array($status, $validStatus)) {
$contents = $response->getBody()->getContents();
$this->logger->warning('Not Valid Status', [
'uri' => $request_uri,
'code' => $status,
'reason' => $reason,
'contents' => $contents
]);
$exception = new HttpException("{$reason}\n{$contents}", $status);
throw new EmptyResponse($request_uri, $exception);
}
@ -80,6 +92,13 @@ abstract class AbstractEndPoint extends LoggerEnabled implements EndPoint
$contents = $response->getBody()->getContents();
if (trim($contents) === '') {
$this->logger->warning("Empty contents", [
'uri' => $request_uri,
'data' => $data,
'code' => $response->getStatusCode(),
'reason' => $response->getReasonPhrase(),
'contents' => $contents
]);
throw new EmptyResponse($request_uri);
}
$json = json_decode($contents, true);