5. Exceptions
Overview
This chapter discusses how exceptions are dealt with in Java. You will first learn how to identify the situations that produce exceptions in your code. This knowledge will simplify the process of handling these exceptions by alerting you to those circumstances in which they are most likely to arise. In this endeavor, this chapter also provides a list of best practices guiding you through common scenarios and the best methods of either catching exceptions or throwing them to the calling class, logging their details as you go. You will further learn to differentiate between different types of exceptions, and practice the techniques for handling each. By the end of the chapter, you will even be able to create your own exception class, capable of logging each type of exception in order of severity.