@@ -638,12 +638,12 @@ const update_stackframes_callback = Ref{Function}(identity)
638
638
const STACKTRACE_MODULECOLORS = Iterators. Stateful (Iterators. cycle ([:magenta , :cyan , :green , :yellow ]))
639
639
const STACKTRACE_FIXEDCOLORS = IdDict (Base => :light_black , Core => :light_black )
640
640
641
- function show_full_backtrace (io:: IO , trace:: Vector ; print_linebreaks:: Bool , prefix= nothing )
641
+ function show_full_backtrace (io:: IO , trace:: Vector ; print_linebreaks:: Bool , prefix:: Union{Nothing,String} = nothing )
642
642
num_frames = length (trace)
643
643
ndigits_max = ndigits (num_frames)
644
644
645
645
println (io)
646
- prefix === nothing || print (io, prefix)
646
+ prefix isa String && print (io, prefix)
647
647
println (io, " Stacktrace:" )
648
648
649
649
for (i, (frame, n)) in enumerate (trace)
@@ -704,7 +704,7 @@ function show_reduced_backtrace(io::IO, t::Vector; prefix=nothing)
704
704
try invokelatest (update_stackframes_callback[], displayed_stackframes) catch end
705
705
706
706
println (io)
707
- prefix === nothing || print (io, prefix)
707
+ prefix isa String && print (io, prefix)
708
708
println (io, " Stacktrace:" )
709
709
710
710
ndigits_max = ndigits (length (t))
@@ -713,7 +713,7 @@ function show_reduced_backtrace(io::IO, t::Vector; prefix=nothing)
713
713
frame_counter = 1
714
714
for i in eachindex (displayed_stackframes)
715
715
(frame, n) = displayed_stackframes[i]
716
- prefix === nothing || print (io, prefix)
716
+ prefix isa String && print (io, prefix)
717
717
print_stackframe (io, frame_counter, frame, n, ndigits_max, STACKTRACE_FIXEDCOLORS, STACKTRACE_MODULECOLORS; prefix)
718
718
719
719
if i < length (displayed_stackframes)
@@ -725,7 +725,7 @@ function show_reduced_backtrace(io::IO, t::Vector; prefix=nothing)
725
725
cycle_length = repeated_cycle[1 ][2 ]
726
726
repetitions = repeated_cycle[1 ][3 ]
727
727
popfirst! (repeated_cycle)
728
- prefix === nothing || print (io, prefix)
728
+ prefix isa String && print (io, prefix)
729
729
printstyled (io,
730
730
" --- the above " , cycle_length, " lines are repeated " ,
731
731
repetitions, " more time" , repetitions> 1 ? " s" : " " , " ---" , color = :light_black )
743
743
# Print a stack frame where the module color is determined by looking up the parent module in
744
744
# `modulecolordict`. If the module does not have a color, yet, a new one can be drawn
745
745
# from `modulecolorcycler`.
746
- function print_stackframe (io, i, frame:: StackFrame , n:: Int , ndigits_max, modulecolordict, modulecolorcycler; prefix= nothing )
746
+ function print_stackframe (io, i, frame:: StackFrame , n:: Int , ndigits_max, modulecolordict, modulecolorcycler; prefix:: Union{Nothing,String} = nothing )
747
747
m = Base. parentmodule (frame)
748
748
modulecolor = if m != = nothing
749
749
m = parentmodule_before_main (m)
766
766
parentmodule_before_main (x) = parentmodule_before_main (parentmodule (x))
767
767
768
768
# Print a stack frame where the module color is set manually with `modulecolor`.
769
- function print_stackframe (io, i, frame:: StackFrame , n:: Int , ndigits_max, modulecolor; prefix= nothing )
769
+ function print_stackframe (io, i, frame:: StackFrame , n:: Int , ndigits_max, modulecolor; prefix:: Union{Nothing,String} = nothing )
770
770
file, line = string (frame. file), frame. line
771
771
772
772
# Used by the REPL to make it possible to open
@@ -781,7 +781,7 @@ function print_stackframe(io, i, frame::StackFrame, n::Int, ndigits_max, modulec
781
781
digit_align_width = ndigits_max + 2
782
782
783
783
# frame number
784
- prefix === nothing || print (io, prefix)
784
+ prefix isa String && print (io, prefix)
785
785
print (io, " " , lpad (" [" * string (i) * " ]" , digit_align_width))
786
786
print (io, " " )
787
787
@@ -791,7 +791,7 @@ function print_stackframe(io, i, frame::StackFrame, n::Int, ndigits_max, modulec
791
791
end
792
792
println (io)
793
793
794
- prefix === nothing || print (io, prefix)
794
+ prefix isa String && print (io, prefix)
795
795
# @ Module path / file : line
796
796
print_module_path_file (io, modul, file, line; modulecolor, digit_align_width)
797
797
@@ -820,7 +820,7 @@ function print_module_path_file(io, modul, file, line; modulecolor = :light_blac
820
820
printstyled (io, basename (file), " :" , line; color = :light_black , underline = true )
821
821
end
822
822
823
- function show_backtrace (io:: IO , t:: Vector ; prefix= nothing )
823
+ function show_backtrace (io:: IO , t:: Vector ; prefix:: Union{Nothing,String} = nothing )
824
824
if haskey (io, :last_shown_line_infos )
825
825
empty! (io[:last_shown_line_infos ])
826
826
end
0 commit comments