Mega Code Archive

 
Categories / Delphi / OOP
 

How to handle exceptions globally

Title: How to handle exceptions globally 1. Declare your custom exception handler: { Public declarations } procedure MyExceptionHandler(Sender : TObject; E : Exception ); 2. Define your exception handler in the "implementation" section: In den Implementations-Abschnitt kommt dieser Code: procedure TForm1.MyExceptionHandler(Sender : TObject; E : Exception ); begin MessageDlg('ERROR: ' + E.Message); end; 3. Assign the created exception handler to your application's OnException event. procedure TForm1.FormCreate(Sender: TObject); begin Application.OnException := MyExceptionHandler; end;