title: Which exception to throw for invalid input which is valid from client perspective
body: <p>I am writing code to find and intersection of 2 lines.
  When slopes of the lines are equal they dont intersect. But on the other hand an input with  slopes of equal value is completely valid. </p>
  
  <pre><code>public static Point calculateIntersection(Line line1, Line line2) {
  
      if (line1 == null || line2 == null) {
          throw new NullPointerException(" some message ");
      }
  
      if (line1.getConstant() == line2.getConstant()) {
          return new Point(0, line1.getConstant());
      }
  
      if (line1.getSlope() == line2.getSlope()) {
          throw new IllegalArgumentException("slopes are same, the lines do not intersect.");
      }
  
      int x = (line2.getConstant() - line1.getConstant()) / (line1.getSlope() - line2.getSlope());
      int y = line1.getSlope() * x + line1.getConstant();
  
      return new Point(x, y);
  }
  </code></pre>
  
  <p>The question is throwing illegal argument exception the right thing to do ? 
  Since input is valid, it does not completely convince me.</p>
  
  <p>Is custom exception the right thing to do ?
  Sounds like a good choice but an additional opinion would help.</p>
  
  <p>Thanks</p>