title: What is the correct way to handle client side and server side errors on the web?
body: <p>I'm new to web development (though not new to WinForms developmet) and I wanted to know the correct and efficient way to handle errors both on the client side as well as the server side.</p>
  
  <p>For example, user enters a bad zip code (using letters), I want to notify the user of the bad zip code entered, how do I handle this? </p>
  
  <p>I'm assuming this would be on the client side but can anyone show me an example code? What scripting language should you use? Should you display a message on the screen? Should you make an error message visible? What is the standard way of doing this?</p>
  
  <p>Example two: user clicks on something that runs a query in a server database. An error occurs. How do I notify the user of the error?</p>
  
  <p>Usually in Win Forms I can just do this:</p>
  
  <pre><code>try
  {
       CreateDirectoriesAndSystemFiles();
  }
  catch (Exception ex)
  {
       ErrorLogger.LogError(ex.Source, ex.TargetSite.ToString(), "Error creating directories!; " + ex.Message);
       MessageBox.Show(ex.Message, "Error creating directories!", MessageBoxButtons.OK, MessageBoxIcon.Error);
       return;
  }
  </code></pre>
  
  <p>How can I mimic the above in a web environment?</p>