Skip to content

Tracebacks printout improvements #3839

@binarybana

Description

@binarybana

In a traceback for the following:

while true
    # lots of lines
    foo = zeros(5)
    foo[8] = 1 # oops
    # lots of lines 
end

we get

$ julia testloop.jl
ERROR: BoundsError()
 in anonymous at no file:4
 in include_from_node1 at loading.jl:91
 in process_options at client.jl:274
 in _start at client.jl:350
at /tmp/testloop.jl:6

compared to the IMHO easier to read Python traceback for an equivalent script:

Traceback (most recent call last):
  File "testloop.py", line 4, in <module>
    foo[8] = 1 # oops
IndexError: list assignment index out of range

Mainly:

  • In the Julia traceback, the line number on the last line printed points to the end statement of the block the error occurred in, but this is not nearly as helpful as line 4 which is at the top of the traceback.
  • The Python traceback prints out the source line that contained the error, often allowing me to figure out the error before (or while) switching to my text editor.
  • The Python traceback is most recent last (saying this explicitly in the printout) which helps for very large tracebacks. It also has the error on the last line rather than the first.

These are all subjective of course, but the logic in the points above seems rather sound to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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