Root > How to... > ...get exception call stack?

...get exception call stack?

Previous pageReturn to chapter overviewNext page   

Option 1

(Delphi 2009+ only)

Assuming you only need a textual representation:

 

except
  on E: Exception do
    Memo1.Lines.Text := E.StackTrace;
end;

 

 

Option 2

Assuming you have access to RTL's exception object:

 

uses
  EExceptionManager, // for ExceptionManager
  EException,        // for TEurekaExceptionInfo 
  ECallStack;        // for TEurekaBaseStackList 
 
var
  EI: TEurekaExceptionInfo;
  CallStack: TEurekaBaseStackList;
// ...
  except
    on E: Exception do
    begin
      EI := ExceptionManager.Info(E);
      if Assigned(EI) then // EI would be nil, if EurekaLog is disabled or event handlers instruct EurekaLog to skip this exception
        CallStack := EI.CallStack;
    end;
  end;

 

Note: due to bugs in some older IDEs, you may need to write like this:

      EI := ExceptionManager.Info(Pointer(E));

 

 

Option 3

Assuming you have access to EurekaLog's exception information object (such as argument in an event handler):

 

uses
  EException, // for TEurekaExceptionInfo 

  ECallStack; // for TEurekaBaseStackList
 
{ ... } AExceptionInfo: TEurekaExceptionInfo; { ... }
var
  CallStack: TEurekaBaseStackList;
begin
  CallStack := AExceptionInfo.CallStack;
end;

 

 

Option 4

Assuming you want call stack for last (e.g. most recent) exception in current thread:

 

uses
  EExceptionManager, // for ExceptionManager
  EException,        // for TEurekaExceptionInfo 

  ECallStack;        // for TEurekaBaseStackList 
 
var
  EI: TEurekaExceptionInfo;
  CallStack: TEurekaBaseStackList;
begin
  EI := ExceptionManager.LastThreadException;
  if Assigned(EI) then // EI would be nil, if EurekaLog is disabled or event handlers instruct EurekaLog to skip this exception
    CallStack := EI.CallStack;
end;

 

 

See also:




Send feedback... Build date: 2018-11-26
Last edited: 2018-06-14
PRIVACY STATEMENT
The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.


Permanent link to this article: https://www.eurekalog.com/help/eurekalog/how_to_get_exception_call_stack.php