When to Use Exception Handling

Out-of-memory and disk-full conditions could occur any time during program execution. A TRY/CATCH sequence at the top level of your application can provide a warning message to the user, followed by a graceful exit.

Routine file exceptions can occur at a lower level in the application. If your program attempts to open a nonexistent file, local CATCH logic can inform the user or take other corrective action. A better alternative, however, might be an explicit test for the file's presence.

If you want your program to keep running after the exception, be very careful to clean up memory by deleting unused objects. Don't forget CString objects that have been allocated on the stack.