Skip to content

Commit

Permalink
Improve exception stack printing
Browse files Browse the repository at this point in the history
The expanded stacktrace printing introduced in #36134 and the fact that
we no longer print errors in red (#36015) makes it harder to distinguish
distinct exceptions in the stack.

Add a newline for this, and print the "caused by" in red. Also remove
exception numbering, which was arguably not very helpful.
  • Loading branch information
c42f committed Jul 10, 2020
1 parent 66f41c5 commit b3d69cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ function show_exception_stack(io::IO, stack::Vector)
nexc = length(stack)
for i = nexc:-1:1
if nexc != i
printstyled(io, "caused by [exception ", i, "]\n", color=:light_black)
printstyled(io, "\ncaused by:\n", color=:red)
end
exc, bt = stack[i]
showerror(io, exc, bt, backtrace = bt!==nothing)
Expand Down
3 changes: 2 additions & 1 deletion test/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ end
nested_error_pattern = r"""
ERROR: DivideError: integer division error
Stacktrace:.*
caused by \[exception 1\]
caused by
UndefVarError: __not_a_binding__ not defined
Stacktrace:.*
"""s
Expand Down

0 comments on commit b3d69cb

Please sign in to comment.