title: When is it suitable to throw an Exception?
body: <p>I've seen some code recently where the author was throwing exceptions for almost every constructor and throwing runtime exceptions for things like the code below, in a method that returns int:</p>
  
  <pre><code>if(condition){
    return 1;
  }
  if(condition){
    return 2;
  }
  if(condition){
    return 3;
  }
  throw new RuntimeException("Unreachable code");
  // method ends here
  </code></pre>
  
  <p>I wouldn't have personally thrown an exception there, because I would have structured it using if and else if statements, and in this particular case your code would be fundamentally wrong for it not to satisfy one of the conditions anyway.</p>
  
  <p>There are plenty of places you could throw runtime exceptions, that would never be reached if you're code is working correctly, sometimes it just seems like the author doesn't trust the code to work, in the case of the code block above. Also, every constructor could throw an exception for if it doesn't initialize correctly, but you could also structure it so that the object would be null - which you could then check for in main, for instance.</p>
  
  <p>What I'm asking, basically, is when is it worth throwing an exception?</p>