Blog

Guzzle - (truncated...)

Some libraries throw a Guzzle Exeption which result in $e->getMessage() is truncated after to 120 character with the text "(truncated...)".

try {
    // 
} catch (\GuzzleHttp\Exception\ClientErrorResponseException $e) {
    throw $e;
} catch (\GuzzleHttp\Exception\RequestException $e) {
    throw $e;
} catch (\GuzzleHttp\Exception\ClientException  $e) {
    throw $e;
}

This could depend on the version of Guzzle. not sure.

A work-arround is to return the full body content:

try {
    //
} catch (\GuzzleHttp\Exception\ClientErrorResponseException $e) {
    throw new \Exception($e->getResponse()->getBody()->getContents());
} catch (\GuzzleHttp\Exception\RequestException $e) {
    throw new \Exception($e->getResponse()->getBody()->getContents());
} catch (\GuzzleHttp\Exception\ClientException  $e) {
    throw new \Exception($e->getResponse()->getBody()->getContents());
}
Zoeken