Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 11
    If the exception is expected, it isn't really an exception. "NoRowsException"? Sounds like control flow to me, and therefore a poor use of an exception. Commented May 31, 2011 at 16:09
  • 1
    @qes: It makes sense to raise an exception whenever a function is unable to calculate a value, e.g. double Math.sqrt(double v) or User findUser(long id). This gives the caller the freedom to catch and handle errors where it is convenient, instead of checking after each call. Commented May 31, 2011 at 20:17
  • 1
    Expected = control flow = anti-pattern of exception. Exception shouldn't be used for control flow. If it's expected to produce error for specific input, then it just be passed a a part of return value. So we have NAN or NULL. Commented Dec 4, 2013 at 5:15
  • 1
    @Eonil ...or Option<T> Commented Apr 26, 2014 at 9:55