I have a function that works on an array and collects the exceptions and backtraces encountered during processing.
For the tests I need to check if something is a backtrace. The following works, but seems very fragile:
typeof(backtrace()) === Array{Union{Ptr{Nothing}, Base.InterpreterIP},1}
Is there a better way to check this?
yha
July 20, 2020, 9:46am
2
Perhaps collect stacktraces rather than backtraces? The docs for stacktrace
say it returns a vector of StackFrame
s, so this should be less fragile:
is_stacktrace(x) = x isa AbstractVector{StackTraces.StackFrame}
2 Likes
Thanks, I did not know that backtraces and stacktraces are different things, and I used catch_backtrace()
, but stacktrace()
can also convert, so it is fine now.
1 Like