Call stack is represented by the TEurekaBaseStackList class from the ECallStack unit.
Important: EurekaLog has to be enabled for this to work. See also.
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);
// EI would be nil, if EurekaLog is disabled
// or event handlers instruct EurekaLog to skip this exception
if Assigned(EI) then
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 (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;
// EI would be nil, if EurekaLog is disabled
// or event handlers instruct EurekaLog to skip this exception
if Assigned(EI) then
CallStack := EI.CallStack;
end;
See also:
Send feedback...
|
Build date: 2024-09-30
Last edited: 2024-06-03
|
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
|
|