Delphi: make sure you show the `ExceptAddr` and `ClassName` if you display in exception in DEBUG mode.
Posted by jpluimers on 2014/03/21
When handling `Application.OnException` add the `ExceptAddr` to in Delphi the menu `Search` -> `Goto address` has a chance of working, and the `ClassName` so you know what happened.
You might want to always do this, depending on how scared your users get from HEX values in error messages.
This works in about every Delphi version I ever used:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
procedure TMainForm.Application_OnException(Sender: TObject; E: Exception); | |
var | |
lMessage: String; | |
begin | |
lMessage := E.Message; | |
{$IFDEF DEBUG} | |
lMessage := Format('%s at $%p: %s', [E.ClassName, ExceptAddr, lMessage]); | |
{$ENDIF DEBUG} | |
BringToFront(); | |
MessageDlg(lMessage, mtError, [mbOK], 0); | |
end; | |
// Application.OnException := Application_OnException; |
–jeroen
Sebastian Jänicke said
Our solution is a unit which resides on top of nearly all other units inside the project’s uses directive. In this unit a handler for exception is created as you showed it. Every exception is logged including the stacktrace and the last 15 user actions.
The advantage is, that even exceptions in initialization and finalization sections are catched.
jpluimers said
Nice solution. How do you keep track of the user actions?