To configure my own exception message, I did the following:
In the private declarations of application's main form:
procedure onExcept(sender: TObject; e: Exception);
In the OnCreate event of the main form:
procedure TfrmMain.formCreate(sender: TObject);
begin
application.onException := @onExcept;
end;
procedure TfrmMain.onExcept(sender: TObject; e: Exception);
begin
//...
end;
It's important to note that the @ operator is required if you're using Lazarus. If I didn't put it, the compiler would consider onExcept
as a function call. Delphi adds it internally, so you don't have to worry about it.
If you want to change this behavior, use {$mode Delphi}
instead of {$mode ObjFPC}
directive.