Confused about the order of TaskFailedException's showerror

In the stacktrace, I typically expect that scrolling all the way up will get me to the “deepest” level of the call stack.

However, when having code in @threads, the resulting exceptions are TaskFailedException that print first their backtrace and then the nested task’s error, which I find contrary to typical practice.

Overwriting showerror with:

function showerror(io::IO, ex::TaskFailedException, bt = nothing; backtrace=true)
    println(io, "TaskFailedException")
    println(io, "Nested Task Exception:")
    show_task_exception(io, ex.original_exception.task)
    if bt !== nothing && backtrace
        println(io, "\n\nAbove TaskFailedException was caused by:")
        show_backtrace(io, bt)

results in stacktraces that force me to scroll back-and-forth much less.

Was there a reason for the order of TaskFailedException’s showerror that I am missing?

Ended up opening a PR in julia for this.

1 Like