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

Unlike in REPL, passing (e, catch_backtrace()) to the @error macro displays unreadable raw stacktrace instead of text representation #1043

Closed
BoZenKhaa opened this issue Jun 23, 2022 · 4 comments

Comments

@BoZenKhaa
Copy link
Contributor

Following code in REPL displays the error message passed through (e, catch_backtrace()) to the @error macro correctly:

julia> try
           a=b
       catch e
           @error "Oh no, exception!" (e, catch_backtrace())
       end
┌ Error: Oh no, exception!
│   (e, catch_backtrace()) =
│    UndefVarError: b not defined
│    Stacktrace:
│      [1] top-level scope
│        @ REPL[8]:2
│      [2] eval
│        @ ./boot.jl:373 [inlined]
│      [3] eval_user_input(ast::Any, backend::REPL.REPLBackend)
│        @ REPL ~/bin/julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/REPL.jl:150
│      [4] repl_backend_loop(backend::REPL.REPLBackend)
│        @ REPL ~/bin/julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/REPL.jl:246
│      [5] start_repl_backend(backend::REPL.REPLBackend, consumer::Any)
│        @ REPL ~/bin/julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/REPL.jl:231
│      [6] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool)
│        @ REPL ~/bin/julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/REPL.jl:364
│      [7] run_repl(repl::REPL.AbstractREPL, consumer::Any)
│        @ REPL ~/bin/julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/REPL.jl:351
│      [8] (::Base.var"#930#932"{Bool, Bool, Bool})(REPL::Module)
│        @ Base ./client.jl:394
│      [9] #invokelatest#2
│        @ ./essentials.jl:716 [inlined]
│     [10] invokelatest
│        @ ./essentials.jl:714 [inlined]
│     [11] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
│        @ Base ./client.jl:379
│     [12] exec_options(opts::Base.JLOptions)
│        @ Base ./client.jl:309
│     [13] _start()
│        @ Base ./client.jl:495
└ @ Main REPL[8]:4

However, in Jupyter, the error message is displayed in the "raw" form:

image

Version:
Julia Version 1.7.2
Commit bf53498635 (2022-02-06 15:21 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
Environment:
JULIA_REVISE_POLL = 1

@fredrikekre
Copy link
Member

logger = Base.CoreLogging.SimpleLogger(Base.stderr)
must be ConsoleLogger to get that pretty printing.

@BoZenKhaa
Copy link
Contributor Author

Thank you, it just works! Is it problematic to run ConsoleLogger as the global logger?

image

@fredrikekre
Copy link
Member

No thats what the REPL does, I don't know why IJulia doesn't. Feel free to make a PR.

@BoZenKhaa
Copy link
Contributor Author

I will do that, thank you very much! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants