title: Throw Exception VS Return Error within a Try,Catch,Finally
body: <p>I'm pretty sure I already know the answer, but I'm still curious what the opinion is on handling an error within a Try,Catch,Finally block -- <em>but when you're repeating yourself.</em></p>
  
  <p><strong>BTW - I'm not talking about User Input - but using that for an example because it is clear and short</strong></p>
  
  <p>Consider this bit of code...</p>
  
  <pre><code>try {    
      if (success) {
          return someSuccessMessage;
      }
      else {
          logError("User input not correct format");
          return someErrorMessage; // repeats itself
      }
  }
  catch (Exception ex) {
      logError(ex.Message);
      return someErrorMessage; // repeats itself
  }
  </code></pre>
  
  <p>Say we have a function, that if it fails we want to return an error message because the exception is irrelevant -- our function did not succeed and the user doesn't need any additional detail.</p>
  
  <p>I've always held the belief that if you can handle the error, avoid the exception -- since it isn't exceptional anymore, but I wondered the opinion about avoiding repeating yourself as well... You could do the following to avoid repeating yourself...</p>
  
  <pre><code>try {    
      if (success) {
          return someSuccessMessage;
      }
      else {
          throw new Exception("User input not correct format");
      }
  }
  catch (Exception ex) {
      logError(ex.Message);
      return someErrorMessage;
  }
  </code></pre>
  
  <p>This isn't the best example, but I was going for brevity to make the point of repeating code.</p>
  
  <p><strong>Exceptions are known to incur a performance penalty, but what are the thoughts about a situation like this?</strong></p>