Card 10/ 10
All 10 cards
RecapDifficulty: Advanced1 min
One Hierarchy, Three Decisions, One Thing Never to Do
Six things this topic established, and where each one was.
| The thing | Where |
|---|---|
| A throw skips every line between the failure and the handler | What Happens the Moment Something Goes Wrong |
Error, checked Exception and RuntimeException are three branches of Throwable | Checked, Unchecked, and the Errors |
| Catch where you can act, declare where the caller has the context, wrap with the cause | Catch It, Declare It, or Wrap It |
A stack trace is captured at the new, top frame first | Following One Exception From the throw |
finally runs on every way out, and must never return | Why finally Runs Even After return |
A resource in the try brackets closes itself, before any catch | try-with-resources |
The one worth carrying: every decision in this topic is about who should deal with the failure. Catching narrowly, declaring upwards and wrapping with a cause are three answers to that question, and an empty catch is a refusal to answer it.