1
0
Fork 0

Include json response bodies in transport exceptions, fixes #9606

pull/9618/head
Jordi Boggiano 2021-01-17 14:13:58 +01:00
parent 7ea17d7db9
commit c33f2615b5
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 8 additions and 1 deletions

View File

@ -515,8 +515,15 @@ class CurlDownloader
@unlink($job['filename'].'~');
}
$exception = new TransportException('The "'.$job['url'].'" file could not be downloaded ('.$errorMessage.')', $response->getStatusCode());
$details = '';
if ($response->getHeader('content-type') === 'application/json') {
$details = ':'.PHP_EOL.substr($response->getBody(), 0, 200).(strlen($response->getBody()) > 200 ? '...' : '');
}
$exception = new TransportException('The "'.$job['url'].'" file could not be downloaded ('.$errorMessage.')' . $details, $response->getStatusCode());
$exception->setResponseInfo($responseInfo);
$exception->setHeaders($response->getHeaders());
$exception->setResponse($response->getBody());
return $exception;
}