# Always show exception type in stack trace?

**URL:** https://discourse.julialang.org/t/always-show-exception-type-in-stack-trace/58010
**Category:** General Usage
**Tags:** exception, stacktrace
**Created:** [March 26, 2021, 11:57am UTC](https://discourse.julialang.org/t/always-show-exception-type-in-stack-trace/58010 "2021-03-26T11:57:14Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tpgillam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tpgillam/32/23052_2.png) [@tpgillam](https://discourse.julialang.org/u/tpgillam)
#### Post date: [March 26, 2021, 11:57am UTC](https://discourse.julialang.org/t/always-show-exception-type-in-stack-trace/58010/1 "2021-03-26T11:57:14Z")

</div>

I observe that stack traces in Julia do not necessarily show the _type_ of the exception that is thrown. For example:

```julia
julia> throw(DomainError("moo"))
ERROR: DomainError with moo:
...snip...

```

includes “DomainError” in the stack trace, but

```julia
julia> throw(ProcessFailedException(Base.Process(Base.Cmd([""]), Ptr{Cvoid}(C_NULL))))
ERROR: failed process: Process(`''`, ProcessExited(-9223372036854775808)) [-9223372036854775808]
...snip...

```

… doesn’t include “ProcessFailedException”. The same lack-of-type-showing occurs for `ErrorException` and `Downloads.RequestError` too. These are just the ones I’ve come across so far, and I’m pretty new to Julia, so I’m sure there are plenty more examples!

I would find it very helpful if the stack trace always explicitly showed the type of the exception that was thrown, rather than it being up to the exception’s implementation of `Base.showerror`.

- If one wishes to handle the exception, it is immediately obvious which type of exception one should handle.
- If writing a custom exception, the onus is not on the writer to ensure that the error message makes the type of the exception clear.

There is also precedent for this in other languages, e.g. Python, Java, Kotlin.

At the moment, if wanting to handle an exception of unknown type, one can run some temporary code like:

```julia
try
    thing_that_throws()
catch e
    println(typeof(e))
    rethrow()
end

```

… but this seems like a step that could be avoided.

Do other people feel the same way?

[For context: I’m using `Downloads.download`, and wish to not abort execution if a particular file does not exist. I was migrating from the old `Base.download` since Julia 1.6 was released yesterday. The old way would throw a `ProcessFailedException`, and the new way a `Downloads.RequestError` when a URL wasn’t accessible – both exceptions of types that eluded me until I used code like the above!]
