The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,969 other subscribers

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:

procedure TMainForm.Application_OnException(Sender: TObject; E: Exception);
lMessage: String;
lMessage := E.Message;
lMessage := Format('%s at $%p: %s', [E.ClassName, ExceptAddr, lMessage]);
MessageDlg(lMessage, mtError, [mbOK], 0);
// Application.OnException := Application_OnException;


2 Responses to “Delphi: make sure you show the `ExceptAddr` and `ClassName` if you display in exception in DEBUG mode.”

  1. 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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: