Skip to content

Commit

Permalink
Overload Base.showerror instead of Base.show for PkgError.
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Feb 20, 2019
1 parent 63fbfae commit cae8b4f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)


###############
Expand Down
6 changes: 6 additions & 0 deletions test/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit cae8b4f

Please sign in to comment.