title: Exception handling the right way for WebClient.DownloadString
body: <p>I was wondering what exceptions I should protect myself against when using <code>WebClient.DownloadString</code>.</p>
  
  <p>Here's how I'm currently using it, but I'm sure you guys can suggest better more robust exception handling.</p>
  
  <p>For example, off the top of my head:</p>
  
  <ul>
  <li>No internet connection.</li>
  <li>Server returned a 404.</li>
  <li>Server timed out.</li>
  </ul>
  
  <p>What is the preferred way to handle these cases and throw the exception to the UI?</p>
  
  <pre><code>public IEnumerable&lt;Game&gt; FindUpcomingGamesByPlatform(string platform)
  {
      string html;
      using (WebClient client = new WebClient())
      {
          try
          {
              html = client.DownloadString(GetPlatformUrl(platform));
          }
          catch (WebException e)
          {
              //How do I capture this from the UI to show the error in a message box?
              throw e;
          }
      }
  
      string relevantHtml = "&lt;tr&gt;" + GetHtmlFromThisYear(html);
      string[] separator = new string[] { "&lt;tr&gt;" };
      string[] individualGamesHtml = relevantHtml.Split(separator, StringSplitOptions.None);
  
      return ParseGames(individualGamesHtml);           
  }
  </code></pre>