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.
8.1
Exceptions
checked against unchecked, try and catch, finally, the exception hierarchy
Open
8.2
throw, throws and your own exception
a custom checked exception, throws, the caller that handles it
Open
8.3
try-with-resources
AutoCloseable, the order of close, a suppressed exception, the old finally
Open
8.4
Wrapping and messages
a cause, a message with the value, wrapping a checked exception, what not to catch
Open
8.5
Reading a stack trace
the frames, the line numbers, Caused by, the first line that matters
Open
8.6
Assertions
assert, -ea, an assertion that fails, why not for user input
Open
8.7
Error and the errors a program cannot catch
StackOverflowError, OutOfMemoryError with a small -Xmx, what a program can do
Open
8.8
Capstone: a parser that reports
a line number, a column, a custom exception, a caller that prints the message
Open