Manipulate the Guzzle exception and get the HTTP body

Asked

Viewed 11 times

0

I would like to deal with Guzzle errors when the server returns 4xx and 5xx status codes. I make a request like this one:

$client = $this->getGuzzleClient();
$request = $client->post($url, $headers, $value);

try {

    $response = $request->send();
    return $response->getBody();

} catch (\Exception $e) {

    //Com posso obter o conteudo do body da exception $e?

}
  • https://docs.guzzlephp.org/en/stable/quickstart.html#exceptions

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.