Interactive error messages for the Julia REPL.
Requires Julia 1.6+.
julia> using Pkg
julia> Pkg.add("InteractiveErrors")
Add using InteractiveErrors to your startup.jl file after using Revise.
If you don't have that installed yet you should install it.
Just start using your REPL normally. Once you hit an error you'll be presented
with an interactive tree representing your stacktrace which you can explore. To
turn interactive errors off and return to using normal stacktraces call
toggle(). Call toggle() again to turn it back on.
Press up and down arrows to move through the stacktrace. Press space to
fold or unfold the currently selected line. A + will appear on folded lines.
Press enter once finished. If you are on a line that references a particular
file then that will present additional options in the next menu. q can be
pressed to exit back to the REPL.
Note: a lot of information is hidden inside some of the folded lines and some is completely stripped from the display (such as method arguments). The default choice of information to display is up for discussion. Unfolding a line containing a file and line number will display the immediate lines surrounding it.
The second menu offers several actions that can be taken on the selected line.
[press: d=done, a=all, n=none]
• [ ] ascend
[ ] descend
[ ] JET
[ ] edit
[ ] retry
[ ] breakpoint
[ ] less
[ ] clipboard
[ ] print
[ ] stacktrace
[ ] exception
[ ] backtrace
Press enter to choose the currently selected line. More than one can be chosen:
ascend(available ifCthulhuis loaded) callsCthulhu.ascendon the selected method.descend(available ifCthulhuis loaded) callsCthulhu.descendon the selected method.JET(available ifJETis loaded) callsJET.report_callon the selected method.editopens default editor on the selected file and line.retryruns the code entered in the REPL again.breakpoint(available ifDebuggeris loaded) sets aDebugger.breakpointon the selected file and line.lessopens the pager on the selected file and line.clipboardcopies the normal Julia stacktrace to the clipboard. Useful for posting bug reports. Don't send the interactive printout as an error message when reporting issues to packages or Julia.printprints out the normal Julia stacktrace tostdout.stacktracereturns the stacktrace object.exceptionreturns the exception object that was caught.backtracereturns the raw backtrace object. ContainsPtrs. Not terribly useful.
More than one action can be selected at once. A common combination is edit
and retry. Press d (for done) once you're finished making your choices.
Additional features are available when certain packages are loaded within the REPL session.
Cthulhu, providesascendanddescendoptions on selected method.Debugger, providesbreakpointon selected method.JET, providesreport_callon selected method.JuliaFormatter, provides syntax formatting for method signatures.OhMyREPL, provides syntax highlighting for source code and method signatures.
Depending on the maintenance burden of compatibility with these packages they
may in future versions become direct dependencies instead of using Requires.
Most of the default coloring in the stack-tree can be adjusted to the user's liking via a simple theming system.
-
current_theme()returns the currently active theme: a nestedNamedTupleof customisation options. -
set_theme!can be used to set your own custom theme that follows the same naming scheme as the default theme. Takes either keyword arguments, or aNamedTuple. -
reset_theme!will reset the theme. -
adjust_theme!can be used if you only want to make some minor adjustments to thecurrent_theme. Takes aNamedTupleor keyword arguments that will bemerged with thecurrent_theme.
The default theme is shown below:
pairs(::NamedTuple) with 19 entries:
:function_name => (bold = true,)
:directory => (color = :light_black,)
:filename => (color = :magenta, bold = true)
:line_number => (color = :green, bold = true)
:user_stack => (color = :green, bold = true)
:system_stack => (color = :red, bold = true)
:stdlib_module => (color = :yellow,)
:base_module => (color = :blue,)
:core_module => (color = :light_black,)
:package_module => (color = :cyan, bold = true)
:unknown_module => (color = :red,)
:inlined_frames => (color = :light_black,)
:toplevel_frames => (color = :light_black,)
:repeated_frames => (color = :red,)
:file_contents => (color = :light_black,)
:signature => (color = :light_black, format = true, highlight = true)
:source => (color = :normal, bold = true, highlight = true)
:line_range => (before = 0, after = 5)
:charset => :unicode
