What is exception handling?

As we have mentioned already, checked exceptions were originally thought to be used for the recoverable conditions when a caller code may do something automatically and take another branch of execution, based on the type of the caught exception and maybe the data it carried. And that is the primary purpose and function of exception handling. 

Unfortunately, such utilization of exceptions proved to be not very productive because as soon as an exceptional condition is discovered, the code is enhanced and makes such a condition one of the possible processing options, albeit not very often executed.

The secondary function is to document the error condition and all the related information for later analysis and code enhancement.

The third and no less important function of exception handling is to protect the application from complete failure. The unexpected condition happened, but hopefully such conditions are rare and the mainstream processing is still available for the application to continue working as it was designed.

The fourth function of exception handling is to provide a mechanism for information delivery in some special cases when other means are not as effective. This last function of exception handling remains controversial and not used very often. We will talk about it in the next section.