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*

23
  • 39
    Regarding throwing Exception, it isn't always because people are lazy, it's also common that you, when you implement frameworks, let users of the framework be able to throw any exception. You can e.g. check the signature of the Callable interface in JSE Commented May 24, 2011 at 19:53
  • 10
    @Kaj - yes, such general things like Callable, interceptors and the likes are special cases. But in most cases it's because people are lazy :) Commented May 24, 2011 at 19:55
  • 8
    re: 3.1 "log it and return" Do so judiciously. This is very close to eating or hiding and exception. I'd do this for something that does not indicate a problem, that is not really exceptional. Logs get flooded and ignored too easily. Commented Jul 25, 2012 at 14:07
  • 7
    "when you want to force the user of your API to think how to handle the exceptional situation" - you cannot force anyone to think if they do not want to. If they do not want to think, they will write a poor exception block that does nothing at all, or worse, deletes or interferes with critical error information. That is why checked exceptions are a failure. Commented Aug 24, 2012 at 13:01
  • 3
    @adrianos "...you cannot force anyone to think if they do not want to...." With this line of thinking we could also remove compile errors.... I'm not really targetting you, I have heard this argument time and again and still find it to be the poorest possible explanation for labeling Checked Exceptions as a failure. As a side note, I have seen before such a language where compile (and runtime errors as well actually) were effectively made impossible by desing. That road led to some very dark places. Commented Aug 11, 2016 at 17:49