Skip to content

Commit

Permalink
precompilepkgs: fix error reporting (#53862)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored Mar 27, 2024
1 parent 653c0ae commit fc2d3af
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions base/precompilation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -944,7 +946,7 @@ function precompilepkgs(pkgs::Vector{String}=String[];
end
else
println(io)
error(err_msg)
throw(PkgPrecompileError(err_msg))
end
end
end
Expand Down

0 comments on commit fc2d3af

Please sign in to comment.