title: Is returning an exception an anti-pattern?
body: <p>I have two simple methods:</p>
  
  <pre><code>public void proceedWhenError() {
     Throwable exception = serviceUp();
  
     if (exception == null) {
        // do stuff
     } else {
        logger.debug("Exception happened, but it's alright.", exception)
        // do stuff
     }
  }
  
  public void doNotProceedWhenError() {
     Throwable exception = serviceUp();
  
     if (exception == null) {
        // do stuff
     } else {
        // do stuff
        throw new IllegalStateException("Oh, we cannot proceed. The service is not up.", exception)
     }
  }
  </code></pre>
  
  <p>The third method is a private helper method:</p>
  
  <pre><code>private Throwable serviceUp() {
      try {
          service.connect();
          return null;
      catch(Exception e) {
         return e;
      }
  }
  </code></pre>
  
  <p>We had a small talk with a colleague of mine about the pattern used here:</p>
  
  <p><strong>returning an <code>Exception</code> (or <code>Throwable</code>) object from the <code>serviceUp()</code> method</strong>.</p>
  
  <p>The first opinion:</p>
  
  <blockquote>
    <p>It is an anti-pattern to use Exceptions to control the workflow and we should only return boolean from
    <code>serviceUp()</code> and never the Exception object itself. The argument is
    that using Exceptions to control the workflow is an anti-pattern.</p>
  </blockquote>
  
  <p>The second opinion:</p>
  
  <blockquote>
    <p>It is alright, as we need to deal with the object afterwards in the
    two first methods differently and whether returning Exception object
    or boolean does not change the workflow at all</p>
  </blockquote>
  
  <p>Do you think 1) or 2) is correct and <strong>especially, why?</strong>
  Note, that the question is ONLY about the method <code>serviceUp()</code> and its return type - <code>boolean</code> vs <code>Exception</code> object.</p>
  
  <p><em>Note: I am not questioning whether to use Throwable or Exception objects.</em></p>