January 2020
Intermediate to advanced
532 pages
13h 31m
English
A general technique to catch exceptions is to enclose any logic in a try-catch block. This is the easiest way to ensure that unexpected errors are handled:
try # do something that may possible raise an errorcatch ex # recover from failure depending on the type of conditionend
A common question, however, is where this try-catch block should be placed. Of course, we could have just wrapped every single line of code but that would be impractical. After all, not every line of code would throw an error.
We do want to be smart about choosing where to catch exceptions. We know that adding exception handling increases the code size. Additionally, every line of code requires maintenance. Ironically, the less code ...
Read now
Unlock full access