Skip to content

Commit 1dcb6d6

Browse files
committed
only print show(err) suggestion for limited types in REPL
fixes #50575
1 parent 0f56da8 commit 1dcb6d6

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

base/errorshow.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -772,9 +772,6 @@ function show_backtrace(io::IO, t::Vector)
772772
if haskey(io, :last_shown_line_infos)
773773
empty!(io[:last_shown_line_infos])
774774
end
775-
# this will be set to true if types in the stacktrace are truncated
776-
limitflag = Ref(false)
777-
io = IOContext(io, :stacktrace_types_limited => limitflag)
778775

779776
# t is a pre-processed backtrace (ref #12856)
780777
if t isa Vector{Any}
@@ -800,9 +797,6 @@ function show_backtrace(io::IO, t::Vector)
800797
# process_backtrace returns a Vector{Tuple{Frame, Int}}
801798
show_full_backtrace(io, filtered; print_linebreaks = stacktrace_linebreaks())
802799
end
803-
if limitflag[]
804-
print(io, "\nSome type information was truncated. Use `show(err)` to see complete types.")
805-
end
806800
nothing
807801
end
808802

stdlib/REPL/src/REPL.jl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,18 @@ function print_response(repl::AbstractREPL, response, show_value::Bool, have_col
283283
end
284284
return nothing
285285
end
286+
287+
function repl_display_error(errio::IO, @nospecialize errval)
288+
# this will be set to true if types in the stacktrace are truncated
289+
limitflag = Ref(false)
290+
errio = IOContext(errio, :stacktrace_types_limited => limitflag)
291+
Base.invokelatest(Base.display_error, errio, errval)
292+
if limitflag[]
293+
print(errio, "\nSome type information was truncated. Use `show(err)` to see complete types.")
294+
end
295+
return nothing
296+
end
297+
286298
function print_response(errio::IO, response, show_value::Bool, have_color::Bool, specialdisplay::Union{AbstractDisplay,Nothing}=nothing)
287299
Base.sigatomic_begin()
288300
val, iserr = response
@@ -292,7 +304,7 @@ function print_response(errio::IO, response, show_value::Bool, have_color::Bool,
292304
if iserr
293305
val = Base.scrub_repl_backtrace(val)
294306
Base.istrivialerror(val) || setglobal!(Base.MainInclude, :err, val)
295-
Base.invokelatest(Base.display_error, errio, val)
307+
repl_display_error(errio, val)
296308
else
297309
if val !== nothing && show_value
298310
try
@@ -315,7 +327,7 @@ function print_response(errio::IO, response, show_value::Bool, have_color::Bool,
315327
try
316328
excs = Base.scrub_repl_backtrace(current_exceptions())
317329
setglobal!(Base.MainInclude, :err, excs)
318-
Base.invokelatest(Base.display_error, errio, excs)
330+
repl_display_error(errio, excs)
319331
catch e
320332
# at this point, only print the name of the type as a Symbol to
321333
# minimize the possibility of further errors.

0 commit comments

Comments
 (0)