title: Correct way to pass errors back to the calling code
body: <p>I have a function called connect like so:</p>
  
  <pre><code>public boolean connnect(){
  {
   ..... connecting codde
   if(connectionSuccessfull)
   {
     return true;
   }
    else
   {
     return false;
   }
  }
  </code></pre>
  
  <p>This is a very basic form of error handling, I want to upgrade this function to handle errors correctly. Such as not just tell me <strong>false</strong> there was an error, but be able to say, error, Authentication failed, or Time-out error etc.
  This information then needs to be sent back up the line to the Caller so it can know what happened.</p>
  
  <p>What is the correct way to go about doing this?</p>
  
  <p>{EDIT}
  In my care its quite probable that an exception will occur I would say 50% of the time.</p>
  
  <p>I have come up with this, does it look partially correct?</p>
  
  <pre><code>namespace MobileWebServices.Exceptions
  {
      //Timeout
  public abstract class TimeOutException : Exception
  {
  
  }
  
  public class ConnectingTimeOutException : TimeoutException
  {
  }
  
  public class DissconnectingTimeOutException : TimeoutException
  {
  
  }
  
  //Authetntication
  public abstract class AuthenticationException : Exception
  {
  
  }
  public class BadAuthenticationException : AuthenticationException
  {
  
  }
  }
  </code></pre>