title: Exceptions in validation
body: <p>I currently have some code that delibratly throws an exception if the user sends me data that fails validation (see below). I like it because im sure any errors in the application are caught and handled. A am however worried the code being slow as throwing exceptions takes a lot of memory. Im also worried it might be "bad code". Whats your advice? Thanks</p>
  
  <pre><code>  public class BTAmendAppointmentRequest
      {
          public DataLayer.WebserviceMessage AddBTAmendAppointmentRequest(DataLayer.BTAmendAppointmentRequest req)
          {
              DataLayer.WebserviceMessage rsp = new DataLayer.WebserviceMessage();
              try
              {
  
                  if (!String.IsNullOrEmpty(req.AppointmentReference))
                      req.AppointmentReference = req.AppointmentReference.Trim();
  
                  if (req.OrderRequestID &lt; 1 || string.IsNullOrEmpty(req.AppointmentReference))
                  {
                      throw new Exception("Amend appointment failed, you must supply a valid appointment reference and order reference");
                  }
  
          ...Do other stuff
              }
              catch (Exception ex)
              {
                  rsp = new Service.WebserviceErrorMessage(ex);
              }
  
  
              return rsp;
  
          }
  
      }
  </code></pre>