private generateException ( Amp\Artax\Response $response ) : |
||
$response | Amp\Artax\Response | HTTP response to generate the exception from |
Результат | exception generated from the response body |
private function generateException(Response $response)
{
$body = $response->getBody();
$status = $response->getStatus();
$info = json_decode($body);
$uri = $response->getRequest()->getUri();
if (isset($info->type, $info->detail)) {
return new AcmeException("Invalid response: {$info->detail}.\nRequest URI: {$uri}.", $info->type);
}
return new AcmeException("Invalid response: {$body}.\nRequest URI: {$uri}.", $status);
}