From fc2d3af5bd8b6a0ba8d057c31129e9318b19f2c5 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Tue, 26 Mar 2024 20:37:46 -0400 Subject: [PATCH] precompilepkgs: fix error reporting (#53862) --- base/precompilation.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/base/precompilation.jl b/base/precompilation.jl index a835b6974d433..8185fe8e8230b 100644 --- a/base/precompilation.jl +++ b/base/precompilation.jl @@ -333,6 +333,8 @@ struct PkgPrecompileError <: Exception msg::String end Base.showerror(io::IO, err::PkgPrecompileError) = print(io, err.msg) +Base.showerror(io::IO, err::PkgPrecompileError, bt; kw...) = Base.showerror(io, err) # hide stacktrace + # This needs a show method to make `julia> err` show nicely Base.show(io::IO, err::PkgPrecompileError) = print(io, "PkgPrecompileError: ", err.msg) @@ -821,7 +823,7 @@ function precompilepkgs(pkgs::Vector{String}=String[]; close(std_pipe.in) # close pipe to end the std output monitor wait(t_monitor) if err isa ErrorException || (err isa ArgumentError && startswith(err.msg, "Invalid header in cache file")) - failed_deps[pkg_config] = (strict || is_direct_dep) ? string(sprint(showerror, err), "\n", strip(get(std_outputs, pkg, ""))) : "" + failed_deps[pkg_config] = (strict || is_direct_dep) ? string(sprint(showerror, err), "\n", strip(get(std_outputs, pkg_config, ""))) : "" delete!(std_outputs, pkg_config) # so it's not shown as warnings, given error report !fancyprint && lock(print_lock) do println(io, " "^9, color_string(" ✗ ", Base.error_color()), name) @@ -944,7 +946,7 @@ function precompilepkgs(pkgs::Vector{String}=String[]; end else println(io) - error(err_msg) + throw(PkgPrecompileError(err_msg)) end end end