From cae8b4fa608a23e02673ff3b9f5608c064889640 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Wed, 20 Feb 2019 13:17:01 +0100 Subject: [PATCH] Overload Base.showerror instead of Base.show for PkgError. --- src/Types.jl | 2 +- test/pkg.jl | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Types.jl b/src/Types.jl index 4f47605768..3e7a5177d8 100644 --- a/src/Types.jl +++ b/src/Types.jl @@ -110,7 +110,7 @@ struct PkgError <: Exception msg::String end pkgerror(msg::String...) = throw(PkgError(join(msg))) -Base.show(io::IO, err::PkgError) = print(io, err.msg) +Base.showerror(io::IO, err::PkgError) = print(io, err.msg) ############### diff --git a/test/pkg.jl b/test/pkg.jl index 93437640a1..bb598d278b 100644 --- a/test/pkg.jl +++ b/test/pkg.jl @@ -683,6 +683,12 @@ end end end +@testset "PkgError printing" begin + err = PkgError("foobar") + @test occursin("PkgError(\"foobar\")", sprint(show, err)) + @test sprint(showerror, err) == "foobar" +end + include("repl.jl") include("api.jl") include("registry.jl")