Logging
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user