You can overload the internal function which is used by stacktrace printing. No guarantee this will keep working, but it ought not to change anything else, like methods(f), at the moment:
julia> function Base.print_type_stacktrace(io, type; color=:normal)
str = first(sprint(show, type, context=io), 20) # <-- only change, could add ... etc.
i = findfirst('{', str)
if isnothing(i) || !get(io, :backtrace, false)::Bool
printstyled(io, str; color=color)
else
printstyled(io, str[1:prevind(str,i)]; color=color)
printstyled(io, str[i:end]; color=:light_black)
end
end
julia> map(+, (((((1,),),),),))
ERROR: MethodError: ...
Stacktrace:
[1] map(f::typeof(+), t::Tuple{Tuple{Tuple{Tu) # <-- trimmed here
@ Base ./tuple.jl:213