Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve error message for size parameter
If the size parameter of the plot is provided in the wrong format, provide a sensible error message. Current the behavior does not provide an indication on where the input problem is: ```julia julia> using Plots julia> plot(size=()) Error showing value of type Plots.Plot{Plots.GRBackend}: ERROR: BoundsError: attempt to access Tuple{} at index [1] Stacktrace: [1] indexed_iterate @ Base ./tuple.jl:92 [inlined] [2] indexed_iterate(t::Tuple{}, i::Int64) @ Base ./tuple.jl:92 [3] prepare_output(plt::Plots.Plot{Plots.GRBackend}) @ Plots ~/.julia/packages/Plots/sxUvK/src/plot.jl:234 [4] display(::Plots.PlotsDisplay, plt::Plots.Plot{Plots.GRBackend}) @ Plots ~/.julia/packages/Plots/sxUvK/src/output.jl:168 [5] display(x::Any) @ Base.Multimedia ./multimedia.jl:340 [6] #invokelatest#2 @ Base ./essentials.jl:887 [inlined] [7] invokelatest @ Base ./essentials.jl:884 [inlined] [8] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{…}) @ REPL ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:315 [9] (::REPL.var"JuliaPlots#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any) @ REPL ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:284 [10] with_repl_linfo(f::Any, repl::REPL.LineEditREPL) @ REPL ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:569 [11] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool) @ REPL ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:282 [12] (::REPL.var"#do_respond#80"{…})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool) @ REPL ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:911 [13] #invokelatest#2 @ Base ./essentials.jl:887 [inlined] [14] invokelatest @ Base ./essentials.jl:884 [inlined] [15] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState) @ REPL.LineEdit ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/LineEdit.jl:2656 [16] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef) @ REPL ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:1312 [17] (::REPL.var"JuliaPlots#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})() @ REPL ~/.julia/juliaup/julia-1.10.0-beta3+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:386 Some type information was truncated. Use `show(err)` to see complete types. ``` which when in the middle of a larger script can be really hard to track, as the error only manifest when the figure is being shown or saved. With this change, we get: ```julia julia> plot(size=()) Error showing value of type Plots.Plot{Plots.GRBackend}: ERROR: ArgumentError: size must be a tuple of length 2 Stacktrace: ``` and ```julia julia> plt = plot(size = ()); julia> savefig(plt, "teste.png") ERROR: ArgumentError: size must be a tuple of length 2 ``` Which are much more clear.
- Loading branch information