Skip to content

Instantly share code, notes, and snippets.

@hinst
Last active August 29, 2015 14:09
Show Gist options
  • Save hinst/ed2afe3e1e2aabf42a2e to your computer and use it in GitHub Desktop.
Save hinst/ed2afe3e1e2aabf42a2e to your computer and use it in GitHub Desktop.
function ExceptionCallStackToStrings: TStringDynArray;
var
i: Integer;
frames: PPointer;
begin
SetLength(result, 1 + ExceptFrameCount);
frames := ExceptFrames;
result[0] := BackTraceStrFunc(ExceptAddr);
for i := 0 to ExceptFrameCount - 1 do
result[i + 1] := BackTraceStrFunc(frames[i]);
end;
function JoinStringArray(aStringArray: TStringDynArray; aSeparator: string): string;
var
i: Integer;
begin
result := '';
for i := 0 to Length(aStringArray) - 1 do
begin
result := result + aStringArray[i];
if i < Length(aStringArray) - 1 then
result := result + aSeparator;
end;
end;
function ExceptionCallStackToText: string;
begin
result := JoinStringArray(ExceptionCallStackToStrings, LineEnding);
end;
function ExceptionToText(e: Exception): string;
begin
result := e.ClassName + ': "' + e.Message + '"' + LineEnding + ExceptionCallStackToText;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment