title: When is it OK to use exception handling for business logic?
body: <p>I think it is accepted that as a general rule in Java (and perhaps any language with exception handling) one should try to avoid using exception handling to actually handle business logic.  In general, if it is expected that a certain situation is supposed to happen, one should check for it and handle it more directly than relying on exception handling to do the checking for you.  For example, the following is not considered good practice:</p>
  
  <pre><code>try{
    _map.put(myKey, myValue);
  } catch(NullPointerException e){
    _map = new HashMap&lt;String, String&gt;();
  }
  </code></pre>
  
  <p>Instead lazy initialization should be accomplished more like this:</p>
  
  <pre><code>if(_map == null){
    _map = new HashMap&lt;String, String&gt;();
  }
  _map.put(myKey, myValue);
  </code></pre>
  
  <p>Of course there could be far more complex logic than simply handling lazy initialization.  So given that this type of thing is usually frowned upon...when, if ever, is it a good idea to rely on an exception happening for certain business logic to occur?  Would it be accurate to say that any instance where one feels compelled to use this approach is really highlighting a weakness of the API being used?</p>