12.5 Runtime Checks
Defensive programming is a pillar of stable apps. Common errors, like connection failures, invalid user inputs, or a missing file can (and should) be caught and handled in whatever way possible. The app might solve some errors automatically, while others might need user interference.
However, not all errors are recoverable. There might be conditions such as logic bugs or violations of assumptions that should never happen in the program. For instance, you would assume a months array to have 12 members, but perhaps somewhere in the code, you encounter a case in which it has only 10 members: November and December are missing! This is probably a coding error that can’t really be “handled”; instead, you have to fix the bug ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access