Logging exceptions

From Lazarus wiki
Revision as of 19:02, 2 September 2010 by Chronos (talk | contribs) (New page: =Handling exceptions= ==Application.OnException== <delphi>procedure TMainForm.CustomExceptionHandler(Sender: TObject; E: Exception); begin ShowMessage(E.Message); end; procedure TMai...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Handling exceptions

Application.OnException

<delphi>procedure TMainForm.CustomExceptionHandler(Sender: TObject; E: Exception); begin

 ShowMessage(E.Message);

end;

procedure TMainForm.FormCreate(Sender: TObject); begin

 Application.OnException := @CustomExceptionHandler;

end;

procedure TMainForm.ButtonClick(Sender: TObject); begin

 raise Exception.Create('Test');

end;</delphi>


Getting stacktrace

Compiler parameters

  • -gl - generate line numbers for debug informations
  • -gm