August 2001
Beginner
482 pages
10h 52m
English
Figuring out where to put your try blocks is probably the hardest part of using exceptions; it is not always obvious which actions might raise an exception. The next question is where to catch the exception. It might be that you'll want to throw all memory exceptions where the memory is allocated, but you'll want to catch the exceptions high in the program where you deal with the user interface.
When trying to determine try block locations, look to where you allocate memory or use resources. Other things to look for are out-of-bounds errors, illegal input, and so forth.
Here's how catching exceptions works: When an exception is thrown, the call stack is examined. The call stack is the list ...
Read now
Unlock full access