title: Code in try block continues executing after exception?
body: <p>I am trying to implement Google+ login on my website and am running into an issue. Here is my code (after creating a Google_Client object):</p>
  <pre><code>try {
      $client-&gt;authenticate($_GET['code']);
  
      $plus = new \Google_Service_Plus($client);
      $person = $plus-&gt;people-&gt;get('me');
  
      $firstName = $person-&gt;modelData-&gt;name-&gt;givenName;
  
  } catch (Google_Auth_Exception $e) {
      $response = array(
          'error' =&gt; 'Error: Authentication exception.'
      );
  } catch (Exception $e) {
      $response = array(
          'error' =&gt; 'Error: Uncaught exception.'
      );
  }
  </code></pre>
  <ol>
  <li><code>$client-&gt;authenticate()</code> throws a Google_Auth_Exception if the code passed to it is invalid</li>
  <li>If authentication failed, then reading properties from the <code>$person</code> object causes fatal errors</li>
  <li><code>$response</code>is echo'd out as a JSON-encoded object</li>
  </ol>
  <p>The problem is that the <code>try/catch</code> code does not seem to be working properly. When authentication fails due to the code in <code>$_GET['code']</code> being invalid, the following response is returned from the script:</p>
  <pre><code>{&quot;error&quot;:&quot;Error: Authentication exception.&quot;}
  </code></pre>
  <p><strong>So far so good</strong> -- the code in the first <code>catch</code> block was executed.</p>
  <p>However, the code in the <code>try</code> block continues to execute in a weird fashion. I say &quot;weird&quot; because in the above form, a bunch of errors (culminating in a fatal error) occur, meaning this line:</p>
  <pre><code>$firstName = $person-&gt;modelData-&gt;name-&gt;givenName;
  </code></pre>
  <p>Is still executed! It should <strong>not</strong> be executed since an exception was thrown on a previous line. If I comment out the above line, the errors are not thrown (again indicating this line is executed, which it shouldn't be).</p>
  <p>Here are the errors outputted due to the above line executing <em>after</em> the exception has been thrown:</p>
  <blockquote>
  <p>Notice: Undefined index: modelData in [...]\google-api-php-client-master\src\Google\Model.php on line 78</p>
  <p>Notice: Trying to get property of non-object in [...]\ajax_handler.php on line 720 [note: this is the line shown above, where the property is being accessed]</p>
  <p>Notice: Trying to get property of non-object in [...]\ajax_handler.php on line 720</p>
  </blockquote>
  <p>Another reason I said &quot;weird&quot; is that if I add this line:</p>
  <pre><code>die('dying before reading property');
  </code></pre>
  <p>Right before the above line (where I read a property), no errors occur, BUT the &quot;dying before reading property&quot; text is not output onto the page! This is weird because the script is clearly still executing code in the try block after the error is thrown (since without this die() line, the line reading the property is executed and results in lots of errors being output). As with before, the code in the catch block is still executed and the JSON is output onto the page.</p>
  <p>What on earth is going on?</p>