© Josh Juneau 2017

Josh Juneau, Java 9 Recipes, 10.1007/978-1-4842-1976-8_9

9. Exceptions and Logging

Josh Juneau

(1)Hinckley, Illinois, USA

Exceptions are a way of describing exceptional circumstances within a program. They are an indicator that something unexpected (exceptional) has occurred. For that reason, exceptions are efficient at interrupting the current flow of the program and signaling that there is something that requires attention. As such, programs that utilize exceptions judiciously benefit from a better control flow and become more robust and informative for the user. Even so, using exceptions indiscriminately can cause performance degradation.

Within Java, exceptions can be thrown or caught. Throwing an exception involves indicating ...

Get Java 9 Recipes: A Problem-Solution Approach, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.