Exceptions, resources and assertions

What happens when a call fails: checked against unchecked exceptions, throw and throws with an exception of your own, try and catch and the finally that runs on every path. try-with-resources closes in the reverse order and keeps a suppressed exception, and wrapping with a cause keeps the original one. A stack trace is read frame by frame, Caused by included; assertions run with -ea and never on user input; and Error covers the two failures a program cannot catch, StackOverflowError and OutOfMemoryError. A parser capstone reports the line and the column of the first mistake.

096 Exceptions checked against unchecked, try and catch, finally, the exception hierarchy Open 097 throw, throws and your own exception a custom checked exception, throws, the caller that handles it Open 098 try-with-resources AutoCloseable, the order of close, a suppressed exception, the old finally Open 099 Wrapping and messages a cause, a message with the value, wrapping a checked exception, what not to catch Open 100 Reading a stack trace the frames, the line numbers, Caused by, the first line that matters Open 101 Assertions assert, -ea, an assertion that fails, why not for user input Open 102 Error and the errors a program cannot catch StackOverflowError, OutOfMemoryError with a small -Xmx, what a program can do Open 103 Capstone: a parser that reports a line number, a column, a custom exception, a caller that prints the message Open

Lessons