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*

6
  • 6
    Checked exceptions are not necessarily unusual. Their defining characteristic is that they represent an error that is both external (i.e., not a bug) and potentially recoverable. In other words, they're exceptions that should be caught by the application. Errors are external and unrecoverable; they're only catchable so applications can log them before exiting. Commented Feb 13, 2020 at 17:06
  • @user560822, idiomatically, Java exceptions are for "not normal" situations softwareengineering.stackexchange.com/a/189225 But they can be used in many ways. Commented Feb 14, 2020 at 20:17
  • 2
    Java's checked exceptions were intended to signal expected error conditions like "file not found" that a robust program should handle. It was an attempt at adding compiler support for forcing the programmer to handle these kinds of common errors. An external error being rare was actually an argument for making what would otherwise be a checked exception into an unchecked exception. Commented Feb 14, 2020 at 20:32
  • Checked exceptions allows you to make something part of the method contract that must be dealt with, just like its result value and parameters are part of its contract -- the compiler will flag breaches of these contracts, whether it is not catching an exception, passing a String where an int is expected or assigning the result to a wrong variable type. Commented Feb 15, 2020 at 16:43
  • Even in languages where exceptions are idiomatic (like Python), I prefer to avoid throwing them in non-exceptional cases because it makes programs a pain to debug when the debugger is breaking in frequently. Commented Feb 22, 2020 at 5:29