# Confused about the order of TaskFailedException's showerror

**URL:** <https://discourse.julialang.org/t/confused-about-the-order-of-taskfailedexceptions-showerror/94679>\
**Category:** Internals & Design\
**Created:** [February 15, 2023, 12:44pm UTC](https://discourse.julialang.org/t/confused-about-the-order-of-taskfailedexceptions-showerror/94679 "2023-02-15T12:44:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nrontsis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nrontsis/32/38535_2.png) [@nrontsis](https://discourse.julialang.org/u/nrontsis)\
**Post date:** [February 15, 2023, 12:44pm UTC](https://discourse.julialang.org/t/confused-about-the-order-of-taskfailedexceptions-showerror/94679/1 "2023-02-15T12:44:14Z")

</div>

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`](https://github.com/JuliaLang/julia/blob/81813164963f38dcd779d65ecd222fad8d7ed437/base/task.jl#L80-L88) with:

```julia
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)
    end
    println(io)
end

```

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?

---

<div class="post-metadata">

**Author:** ![nrontsis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nrontsis/32/38535_2.png) [@nrontsis](https://discourse.julialang.org/u/nrontsis)\
**Post date:** [February 17, 2023, 2:23pm UTC](https://discourse.julialang.org/t/confused-about-the-order-of-taskfailedexceptions-showerror/94679/2 "2023-02-17T14:23:40Z")

</div>

Ended up opening [a PR in julia](https://github.com/JuliaLang/julia/pull/48706) for this.
