Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResolverError coloring should be decided in showerror, not on construction #4006

Open
danielwe opened this issue Aug 27, 2024 · 1 comment
Open

Comments

@danielwe
Copy link

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

function logstr(pkgID, args...)
# workout the string with the color codes, check stderr to decide if color is enabled
return sprint(args; context=stderr::IO) do io, iargs
printstyled(io, iargs...; color=pkgID_color(pkgID))
end
end

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
Copy link
Author

The most straightforward solution here is perhaps to use 1.11's new StyledStrings stdlib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant