PDA

View Full Version : How to retrieve exception type, message in ExceptionNotify


RHabedank
07-May-2005, 05:34 PM
I'd like to be able to retrieve the exception type (item 2.4 in .elf file) and the exception message (item 2.5 in .elf file) in my ExceptionNotify event handler. This information would be logged in an application event log (text file).

What's the best way to approach this? I've just upgraded to v5 EurekaLog.

Thanks,

Rich Habedank

admin
11-May-2005, 12:17 PM
I'd like to be able to retrieve the exception type (item 2.4 in .elf file) and the exception message (item 2.5 in .elf file) in my ExceptionNotify event handler. This information would be logged in an application event log (text file).

What's the best way to approach this? I've just upgraded to v5 EurekaLog.

Thanks,

Rich Habedank

Use an ExceptionNotify event like this:

uses ExceptionLog, ECore, ETypes; // The required units...

// This is a normal procedure (not a method)...
procedure MyNotify(ExcRecord: TEurekaExceptionRecord; var Handled: Boolean);
Var
Error: Exception;
ErrorType, ErrorMessage: string;
begin
ErrorType := ExcRecord.ExceptionObject.ClassName;
if (ExcRecord.ExceptionObject is Exception) then
begin
Error := Exception(ExcRecord.Exceptionbject);
ErrorMessage := Error.Message;
end;
end;

I hope that this can help you, otherwise don't hesitate to recontact me, ok? :-)