Skip to content

Display of exception stacks could be better #31257

@fredrikekre

Description

@fredrikekre

To me the new exception stack printing (#30900) is not so clear, compare with e.g. this reduced example:

$ cat foo.jl 
function foo()
    error("hello")
end
foo()

which displays on master as

$ julia-master --color=yes foo.jl 
ERROR: Error while loading expression starting at /home/fredrik/foo.jl:4
caused by [exception 1]
hello
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [...]
 [8] _start() at ./client.jl:476

and on Julia 1 as

$ julia11 --color=yes foo.jl 
ERROR: LoadError: hello
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [...]
 [8] _start() at ./client.jl:436
in expression starting at /home/fredrik/foo.jl:4

I have two problems with the new printing:

  1. From the output on master it took me quite a while to understand that the hello output actually came from the ERROR: two lines above. IMO it was more clear before what the error was, and I suggest this should be printed as

    $ julia-master --color=yes foo.jl 
    ERROR: hello
    while loading expression starting at /home/fredrik/foo.jl:4
    caused by [exception 1]
    Stacktrace:
     [1] error(::String) at ./error.jl:33
     [...]
     [8] _start() at ./client.jl:476
    

    instead. It seems more important to print the message before the location.

  2. When seeing caused by [exception 1] I would expect a list of exceptions somewhere where I can look up what exception 1 is. What is exception 1 in the case above? It is not clear to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    display and printingAesthetics and correctness of printed representations of objects.error handlingHandling of exceptions by Julia or the user

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions