Pkg.jl icon indicating copy to clipboard operation
Pkg.jl copied to clipboard

`ResolverError` coloring should be decided in `showerror`, not on construction

Open danielwe opened this issue 5 months ago • 1 comments

A ResolverError has color hardcoded in the message if stderr supports color, as the message is formatted on construction using the following function:

https://github.com/JuliaLang/Pkg.jl/blob/8b2c0f32939042e5d77da05d2825de6ec56487e9/src/Resolve/graphtype.jl#L571-L576

This is unfortunate when the error message isn't actually printed to stderr, for example in Pluto:

image

Perhaps it would be better to store data rather than a preformatted message in the ResolverError object, and only format the message in the showerror(io, ::ResolverError) method, with or without color depending on io.

danielwe avatar Aug 27 '24 20:08 danielwe