Core Java

Exceptions, Assertions, and Logging

Copyright © Cay S. Horstmann 2016

Use exceptions to report errors in a program

Dealing with Errors

The Classification of Exceptions

except

Declaring Checked Exceptions

Throwing Exceptions

Creating Exception Classes

Catch exceptions to remedy error conditions

Catching an Exception

Catching Multiple Exceptions

Rethrowing and Chaining Exceptions

The finally Clause

The Try-with-resources Statement

The Stack Trace

stackTrace

Know how to use exceptions effectively

exceptional

Tips for Using Exceptions

Tips for Using Exceptions

Tips for Using Exceptions

Use assertions to enforce algorithm constraints

The Assertion Concept

Assertion Enabling and Disabling

When to Use Assertions

Use logging to record what your program does

Advantages of the Logging API

Logging 101

Loggers

Levels

Logging Program Flow

Configuration

Handlers

logging