As others have stated...JCL has some nice features...
In your application...You need to set up some info to get the necessary Stack Frame for the Hook...
Project-->Compiler->Stack Frames...I also have all the Debugging checked and add the following...Project->Options->Linker->Map file(Select Detailed)/Include TD32 debug Info
In my Logger unit...I have this...You'll have to have your own TLogger...that saves the info for you...
use
JclDebug, JclHookExcept;
procedure HookGlobalException(ExceptObj: TObject; ExceptAddr: Pointer; OSException: Boolean);
var
a_List: TStringList;
a_Error: string;
begin
if Assigned(TLogger._Instance) then
begin
a_List := TStringList.Create;
try
a_List.Add(cStar);
a_Error := Exception(ExceptObj).Message;
a_List.Add(Format('{ Exception - %s }', [a_Error]));
JclLastExceptStackListToStrings(a_List, False, True, True, False);
a_List.Add(cStar);
// save the error with stack log to file
TLogger._Instance.AddError(a_List);
finally
a_List.Free;
Raise Exception.Create(a_Error);
end;
end;
end;
initialization
Lock := TCriticalSection.Create;
Include(JclStackTrackingOptions, stTraceAllExceptions);
Include(JclStackTrackingOptions, stRawMode);
// Initialize Exception tracking
JclStartExceptionTracking;
JclAddExceptNotifier(HookGlobalException, npFirstChain);
JclHookExceptions;
finalization
JclUnhookExceptions;
JclStopExceptionTracking;
Lock.Free;
end.