Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors coming from show methods are not interactive? #10

Open
rafaqz opened this issue May 12, 2021 · 3 comments
Open

Errors coming from show methods are not interactive? #10

rafaqz opened this issue May 12, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@rafaqz
Copy link

rafaqz commented May 12, 2021

When something is shown in the REPL and show throws an error, the stack trace is normal, not interactive.

@MichaelHatherly
Copy link
Owner

Thanks for reporting.

A reproducible error below. I assume this is what you're refering to, yes?

julia> struct T end

julia> Base.show(io::IO, ::T) = error("bad!")

julia> T()
Error showing value of type T:
ERROR: bad!
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:33
  [2] show(io::IOContext{Base.TTY}, #unused#::T)
    @ Main ./REPL[2]:1
  [3] show(io::IOContext{Base.TTY}, #unused#::MIME{Symbol("text/plain")}, x::T)
    @ Base.Multimedia ./multimedia.jl:47
  [4] display(d::REPL.REPLDisplay{REPL.LineEditREPL}, mime::MIME{Symbol("text/plain")}, x::T)
    @ OhMyREPL ~/.julia/packages/OhMyREPL/07uNa/src/output_prompt_overwrite.jl:8
  [5] display(d::REPL.REPLDisplay, x::Any)
    @ REPL ~/usr/julia/1.6/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:225
  [6] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:328
  [7] #invokelatest#2
    @ ./essentials.jl:708 [inlined]
  [8] invokelatest
    @ ./essentials.jl:706 [inlined]
  [9] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL ~/usr/julia/1.6/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:247
 [10] (::REPL.var"#40#41"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL ~/usr/julia/1.6/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:231
 [11] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/usr/julia/1.6/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:462
 [12] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL ~/usr/julia/1.6/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:229
 [13] (::REPL.var"#do_respond#61"{Bool, Bool, REPL.var"#72#82"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL ~/usr/julia/1.6/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:798
 [14] #invokelatest#2
    @ ./essentials.jl:708 [inlined]
 [15] invokelatest
    @ ./essentials.jl:706 [inlined]
 [16] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/usr/julia/1.6/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2441
 [17] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/usr/julia/1.6/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:1126
 [18] (::REPL.var"#44#49"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ./task.jl:411

julia> toggle()
false

julia> T()
Error showing value of type T:
ERROR: bad!
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:33
  [2] show(io::IOContext{Base.TTY}, #unused#::T)
    @ Main ./REPL[2]:1
  [3] show(io::IOContext{Base.TTY}, #unused#::MIME{Symbol("text/plain")}, x::T)
    @ Base.Multimedia ./multimedia.jl:47
  [4] display(d::REPL.REPLDisplay{REPL.LineEditREPL}, mime::MIME{Symbol("text/plain")}, x::T)
    @ OhMyREPL ~/.julia/packages/OhMyREPL/07uNa/src/output_prompt_overwrite.jl:8
  [5] display(d::REPL.REPLDisplay, x::Any)
    @ REPL ~/usr/julia/1.6/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:225
  [6] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:328
  [7] #invokelatest#2
    @ ./essentials.jl:708 [inlined]
  [8] invokelatest
    @ ./essentials.jl:706 [inlined]
  [9] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL ~/usr/julia/1.6/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:247
 [10] (::REPL.var"#40#41"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL ~/usr/julia/1.6/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:231
 [11] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/usr/julia/1.6/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:462
 [12] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL ~/usr/julia/1.6/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:229
 [13] (::REPL.var"#do_respond#61"{Bool, Bool, REPL.var"#72#82"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL ~/usr/julia/1.6/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:798
 [14] #invokelatest#2
    @ ./essentials.jl:708 [inlined]
 [15] invokelatest
    @ ./essentials.jl:706 [inlined]
 [16] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/usr/julia/1.6/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2441
 [17] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/usr/julia/1.6/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:1126
 [18] (::REPL.var"#44#49"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ./task.jl:411

Disabling interactive errors with toggle() doesn't appear to change the stack at all so it would appear that this isn't handled by the same code path as the rest of the error printing... You can also see that the stacktrace isn't cleaned up at all like it should, there's REPL internals printed. This may be something that's actually an upstream issue perhaps.

@MichaelHatherly MichaelHatherly added the bug Something isn't working label May 12, 2021
@rafaqz
Copy link
Author

rafaqz commented May 12, 2021

Yep, exactly. Somehow my attrempt at a MWE was throwing an unrelated problem with display.

@MichaelHatherly
Copy link
Owner

Even if this could be regarded as just an upstream issue, I'd like to fix it here anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants