title: Guzzle 6.x and catching exceptions / PHP
body: <p>I am PUTing to a restful blog API.  There is simple error checking in the API.  If the entry_name or entry_body is less than 8 characters, he response is as follows:</p>
  
  <pre><code>{
    "status":"failure",
   "message":{
          "entry_name":"The entry_name field must be at least 8 characters in length.",
          "entry_body": The entry_body field must be at least 8 characters in length." 
          }
  }
  </code></pre>
  
  <p>In my web page I get this:</p>
  
  <pre><code>Type: GuzzleHttp\Exception\ClientException
  
  Message: Client error: `PUT https://www.example.com/api/v1/Blog/blog`   
  resulted in a `400 Bad Request` response: {"status":"failure","message":
  {"entry_name":"The entry_name field must be at least 8 characters in 
  length.","entry_body" (truncated...)
  </code></pre>
  
  <p>I don't understand how I can catch the exception prior to guzzle spilling out the error like above.  </p>
  
  <p>I want to test for failure and if failure i want to display the message(s).</p>
  
  <p>This is the code I have to catch exceptions:</p>
  
  <p>This is my code:   </p>
  
  <pre><code>         try {
                $response = $client-&gt;request('PUT', $theUrl);
                $theBody = $response-&gt;getBody();
          } catch (RequestException $e) {
              echo $e;
          }   
  </code></pre>
  
  <p>but it sails right past the above block :-(</p>