Last active
August 29, 2015 14:09
-
-
Save hinst/ed2afe3e1e2aabf42a2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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