Skip to content

Suggestion: abbreviate stack traces by default #40138

@BioTurboNick

Description

@BioTurboNick

I'd like to suggest abbreviating the display of stack traces in errors by default, with the ability to display the full trace immediately after if you wish to see it.

As an example, this stack trace from when BenchmarkTools.@btime errors:

ERROR: UndefVarError: k not defined
Stacktrace:
 [1] var"##core#271"()
   @ Main ~\.julia\packages\BenchmarkTools\Kt6kv\src\execution.jl:371
 [2] var"##sample#272"(__params::BenchmarkTools.Parameters)
   @ Main ~\.julia\packages\BenchmarkTools\Kt6kv\src\execution.jl:377
 [3] _run(b::BenchmarkTools.Benchmark{Symbol("##benchmark#270")}, p::BenchmarkTools.Parameters; verbose::Bool, pad::String, kwargs::Base.Iterators.Pairs{Symbol, Integer, NTuple{4, Symbol}, NamedTuple{(:samples, :evals, :gctrial, :gcsample), Tuple{Int64, Int64, Bool, Bool}}})
   @ Main ~\.julia\packages\BenchmarkTools\Kt6kv\src\execution.jl:405
 [4] #invokelatest#2
   @ .\essentials.jl:710 [inlined]
 [5] #run_result#39
   @ ~\.julia\packages\BenchmarkTools\Kt6kv\src\execution.jl:32 [inlined]
 [6] run(b::BenchmarkTools.Benchmark{Symbol("##benchmark#270")}, p::BenchmarkTools.Parameters; progressid::Nothing, nleaves::Float64, ndone::Float64, kwargs::Base.Iterators.Pairs{Symbol, Integer, NTuple{5, Symbol}, NamedTuple{(:verbose, :samples, :evals, :gctrial, :gcsample), Tuple{Bool, Int64, Int64, Bool, Bool}}})
   @ BenchmarkTools ~\.julia\packages\BenchmarkTools\Kt6kv\src\execution.jl:94
 [7] #warmup#47
   @ ~\.julia\packages\BenchmarkTools\Kt6kv\src\execution.jl:141 [inlined]
 [8] warmup(item::BenchmarkTools.Benchmark{Symbol("##benchmark#270")})
   @ BenchmarkTools ~\.julia\packages\BenchmarkTools\Kt6kv\src\execution.jl:141
 [9] top-level scope
   @ ~\.julia\packages\BenchmarkTools\Kt6kv\src\execution.jl:481

An improved experience might be something like:

ERROR: UndefVarError: k not defined
in var"##core#271"()
   @ Main ~\.julia\packages\BenchmarkTools\Kt6kv\src\execution.jl:371
Use `stacktrace(errs)` to retrieve the full stack trace.

Related to #36517, where @vtjnash mentioned the possibility of a errs variable that stores an error similar to ans storing the last result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    REPLJulia's REPL (Read Eval Print Loop)error handlingHandling of exceptions by Julia or the user

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions