RandomClear icon

How to get call stack for last exception

RandomClear | PRO | 05/20/15 10:51:37 PM UTC | 0 ⭐ | 9716 👁️ | Never ⏰ | []
Delphi |

1.11 KB

|

None

|

0 👍

/

0 👎

// See also: http://pastebin.com/46QkwZNi - "how to convert call stack to text"
// See also: http://pastebin.com/rdNbEwPH - "how to get call stack on demand"
// See also: http://pastebin.com/ACtr0r6S - "how to silently log exception"
// See also: http://pastebin.com/sBn3PA1r - "how to create hang/deadlock report on demand"
 
// Option 1:
 
except
  on E: Exception do
    Memo1.Lines.Text := E.StackTrace;
end;
 
// Option 2:
 
uses
  EExceptionManager,
  EException;
 
var
  EI: TEurekaExceptionInfo;
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
    Memo1.Lines.Text := EI.CallStack.ToString;
end;
 
// Option 3:
 
uses
  EExceptionManager,
  EException;
 
var
  EI: TEurekaExceptionInfo;
// ...
  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
        Memo1.Lines.Assign(EI.CallStack);
    end;
  end;

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎