erg icon indicating copy to clipboard operation
erg copied to clipboard

Better error indication

Open mtshiba opened this issue 3 years ago • 0 comments

f x =
    ...
    y = foo.try_some(x)?
    ...

g x =
    y = f(x)?
    ...

i = g(1)?

Suppose you get the following error in the above code (including omissions).

Traceback (most recent call first):
    ...
    Foo.try_some, line ..., file "..."
    .... | y = foo.try_some(x)?
    module::f, line ..., file "..."
    .... | y = f(x)?
    module::g, line ..., file "..."
    .... | i = g(1)?
Error: ...

How about displaying the contents and type of the variable to make the error message clearer? Like this:

Traceback (most recent call first):
    ...
    Foo.try_some, line ..., file "..."
    .... | y = foo.try_some(x)?
               │            └ 1: Int
               └ <Foo object>: Foo
    module::f, line ..., file "..."
    ... | y = f(x)?
                └ 1: Int
    module::g, line ..., file "..."
    ... | i = g(1)?
Error: ...

mtshiba avatar Aug 10 '22 14:08 mtshiba