title: Custom exception handling and usage for laboratory web site
body: <p>I know similar things have been asked before but it doesn't remove my doubts on the matter.</p>
  
  <p>Around all my pages Page_Load methodes and every other methode that calls a methode that connects to the database, I put my code inside a try catch statement:</p>
  
  <pre><code>try {
      //Some code
  
  }
  //When something goes wrong, catch the exception and translate it into understandable language for the end user.
  catch (LaboratoryException ex) {
      switch (ex.Code) {
          case LaboratoryExceptionCode.GROUP_NOTFOUND: ErrorMessage.Text += "&lt;p class='error'&gt;You didn't enter the correct parameters."; break;
          default: ErrorMessage.Text += "&lt;p class='error'&gt;An unknown error occurred"; break;
      }
      switch (ex.Fault) {
          case LaboratoryExceptionFault.FAULT_CONSUMER: ErrorMessage.Text += " - We think you should check your entered parameters.&lt;/p&gt;"; break;
          case LaboratoryExceptionFault.FAULT_SERVER: ErrorMessage.Text += " - Oops, our bad.&lt;/p&gt;"; break;
          default: break;
      }
  }
  </code></pre>
  
  <p>Is it wise to use a custom exception for every type of error?</p>
  
  <ul>
  <li>If a group is not found in my database (like in the above code.);</li>
  <li>If a group exists;</li>
  <li>When a group cannot be updated;</li>
  <li>When a group has reached the max amount of members (5);</li>
  <li>etc.;</li>
  </ul>
  
  <p>Or is it best to limit this way of error handling?
  I know why and when, but I don't know when too much is too much or where you have to draw the line.</p>
  
  <p>A follow up question, I have a limitation to the amount of people that can be in a group, this limitation, when do I enforce this in my code? In the code behind class of the page? Or when I make a connection to the database? Or both?</p>