#1
|
|||
|
|||
Global exception handler
Although it's easy enough to catch errors (or exceptions) using "try / catch" blocks, some applications might benefit from having a global exception handler. For example, you may want your own global exception handler to handle "common" errors such as "divide by zero," "out of space," etc. Thanks to TApplication's "OnException" event -- which occurs when an unhandled exception occurs in your application, it only takes three (or so) easy steps get our own exception handler going:1. Declare your custom exception handler in your form's "public declarations" section. For example, if your form is named "Form1:"
procedure TForm1.FormCreate(Sender: TObject); begin { begin new code } Application.OnException := MyExceptionHandler; { end new code } end; |