Vorrei gestire gli errori di Guzzle quando il server restituisce i codici di stato 4xx e 5xx. Faccio una richiesta del genere:Handle Guzzle exception e get HTTP body
$client = $this->getGuzzleClient();
$request = $client->post($url, $headers, $value);
try {
$response = $request->send();
return $response->getBody();
} catch (\Exception $e) {
// How can I get the response body?
}
$e->getMessage
restituisce informazioni codice, ma non il corpo della risposta HTTP. Come posso ottenere il corpo della risposta?
Questa domanda è legata a questa domanda http://stackoverflow.com/questions/17658283/catching-exceptions-from-guzzle/28416973#28416973 e le risposte ci potrebbe essere di qualche aiuto, anche. – Trendfischer