Tip: Get Current Callstack with a Collectible Error

The Code

codeunit 50104 "Get Callstack"
{
    SingleInstance = true;

    [ErrorBehavior(ErrorBehavior::Collect)]
    procedure GetCallstack() Callstack: Text
    var
        LF: Char;
    begin
        LF := 10;
        Error(ErrorInfo.Create('', true));
        Callstack := GetCollectedErrors(true).Get(1).Callstack;
        exit(Callstack.Substring(Callstack.IndexOf(Format(LF)) +...

Continue Reading james’s Article on their blog

Tip: Get Current Callstack with a Collectible Error

The Code codeunit 50104 “Get Callstack” { SingleInstance = true; [ErrorBehavior(ErrorBehavior::Collect)] procedure GetCallstack() Callstack: Text var LF: Char; begin LF := 10; Error(ErrorInfo.Create(”, true)); Callstack := GetCollectedErrors(true).Get(1).Callstack; exit(Callstack.Substring(Callstack.IndexOf(Format(LF)) + 1)); end; } Yea, but…why? I dunno, I was just curious whether it was possible. And, it is ? Any sensible applications are probably going to…

Blog Syndicated with james’s Permission

Author: James Pearson

Share This Post On
Share via
Copy link
Powered by Social Snap