Catch Block Triage¶
Run the Catch Block Triage MicroSim Fullscreen
About This MicroSim¶
Every catch block in this sim has the same shape: try something, catch what goes wrong. What differs is what the catch does with the failure. Some do nothing. Some print the error and carry on. Some return a result that looks clean. A few handle a named failure on purpose and let everything else keep traveling.
You judge ten cards, one at a time, against three verdicts:
- Swallows the failure: the code carries on as if nothing went wrong, and nothing outside the code learns about it.
- Turns it into a false answer: the code returns a result that looks like success or a clean result.
- Handles it on purpose: the code deals with a failure it understands, or tells someone plainly, and lets other failures keep traveling.
If a card fits both "false answer" and "swallows," the false answer wins, because a wrong answer does more harm than a missing one. The code is illustrative, written the way an agent might write it for an app like the one in this book.
How to Use¶
- Read the code on card 1. Look at the catch part.
- Hover a verdict button to read what it means, or press Show hint to see all three.
- Pick a verdict and press Check. You get one try per card. The sim shows the right verdict and why.
- Press Next card and work through all ten in order.
- Click any numbered dot you have already checked to read that card again.
- After card 10, the summary groups the cards by verdict and marks the ones you missed. Getting 8 of 10 right is mastery.
Iframe Embed Code¶
You can add this MicroSim to any web page by adding this to your HTML:
<iframe src="https://arunbatchu.github.io/good-enough-engineering/sims/catch-block-triage/main.html"
height="526px"
width="100%"
scrolling="no"></iframe>
Lesson Plan¶
Grade Level¶
Adult professional (Good Enough Engineering)
Duration¶
10-15 minutes
Prerequisites¶
Errors and exceptions, try-catch blocks, bare catch blocks, named failures, the "not checked" result, and the no false all-clear rule (Chapters 1, 9 and 12).
Activities¶
- Exploration (3 min): Open the hint and read the three verdicts. Read card 1 and say out loud what happens after the catch runs.
- Guided Practice (7 min): Judge all ten cards. After each Check, read the Why text before moving on.
- Assessment (5 min): Pick one card you missed. Rewrite its catch block so it handles the failure on purpose, then compare it with cards 3, 6, 8 and 10.
Assessment¶
- 8 of 10 cards judged correctly on the first try.
- Can explain why printing an error (card 4) does not count as handling it.
- Can explain why a catch that catches everything (card 10) can still be handled on purpose.
References¶
- Chapter 12: Errors, Logs and Knowing What Happened - the chapter this sim belongs to.
- try...catch - MDN Web Docs reference for the statement every card uses.