Exceptions
Cheat sheet · https://pcornel.dk/topic.php?topic=5222
Answer
Exceptions represent abnormal execution paths that interrupt normal control flow. Reliable scripting catches only where recovery or context can be added, preserves cause and never treats handled as resolved automatically.
Remember
- Exception caught ≠ error resolved; catch blocks can hide an unresolved target failure.
- Retry after exception ≠ safe automatically; side effects may have partially completed before the error surfaced.
- Generic catch-all ≠ resilience; broad handlers can suppress defects and destroy useful stack/context.
- Cleanup failure ≠ original failure automatically; both may need to be preserved when finalization also fails.
First checks
try { … } catch { … }— PowerShelltry/except in Python— exceptionstrap 'cleanup' ERR EXIT— Bash cleanup
Verify in this order
error → exception → handle/cleanup → exit code
Where it usually breaks
A caught exception proves only that code intercepted a failure signal; it does not prove the failed operation was undone, retried safely or resolved.
Script/input → command/module binding → local/remoting session → request accepted → command result → target object read-back → effective runtime state → workload.
Exceptions scripting boundary map
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Input / runtime | Effective inputs, runtime, working context and dependency versions are explicit | Hidden defaults, stale environment, wrong interpreter/path or unvalidated input |
| Logic / execution | Branch/function/module decisions and external actions expose per-operation results | Swallowed failures, shell reinterpretation, blind retries or last-result-wins behavior |
| Result / proof | Exit/exception/log evidence is correlated with independent target read-back | Process success or printed output treated as target success |
| Recovery / troubleshooting | First failed boundary is preserved, changed minimally and retested | Random edits, catch-all suppression or evidence destroyed before diagnosis |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5222