Handling exceptions gracefully

Both Modula-2 and Ada95 have exception mechanisms and they arevery similar. Generally it is best to handle all exceptions somewhere in your code.By "handle" we mean have the code continue normal operation as though theexception was not raised. You should probably notify the user of the error situationand tell them to attempt to save and exit your program immediately. Most times theuser will be able to to this, and you can help keep the user from losing any workdone because of the crash.

For a Windows type application handling all exceptions in allcall back procedures is an ideal location. For a non event driven application yousimply choose an appropriate procedure in the program to place your handler.

32-bit programs have the additional advantage of trapping accessviolations in addition to normal language checking options. In fact this is probablythe most useful unknown exception to trap. For Modula-2 an access violation is EXCEPTIONS.sysException.For Ada95 the exception is Access_Violation.

You can also use the post mortem call tracefeature of the runtime system to help you track down the unhandled exceptions.