title: Best way to Try/Catch HTTP response in Google Script
body: <p>I'm still new to JavaScript and Google apps script, and this is the first time I'm trying to use a 'Try/Catch' statement. </p>
  
  <p>I'm running a script that connects to a page. It connects most of the time without issue, but occasionally it won't respond and throw a http error (Or, the response will be empty). I want to try/catch this response to have it run a second time if I get an error code, but I'm not 100% sure I understand the syntax, because no matter how I format it, It either never throws the exception, or always throws it.</p>
  
  <p>Here is some sample code I've been experimenting with: </p>
  
  <pre><code>function myFunction() {
    var response =  UrlFetchApp.fetch("google.com"); 
    Logger.log('Response Code: ' + response.getResponseCode());
  
  try {if(response.getResponseCode() === 200);
  } catch (err) {
      throw 'Page connected';
  }
  }
  </code></pre>
  
  <p>If I can get this to work, I'm sure I can figure out the rest. However, even though the log shows me I get a HTTP response of 200, it never throws the error 'Page connected'. </p>
  
  <p>If someone can guide me on: </p>
  
  <p>1) Is this the correct method to achieve what I want, or is Try/Catch for something else?
   2) The correct syntax.</p>
  
  <p>I would be very grateful.  </p>