-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Remove enforcal of printing exceptions as red #36015
Comments
I guess just printing |
Although I don't feel strongly about it, the fully red messages are somewhat useful when the log is slightly long, and the color is no longer helpful when the log is "very" long. The coloration is auxiliary function, so I don't think designers of exceptions should specify the colors actively. If desired, you can specify the function Base.showerror(io::IO, ce::CustomException)
printstyled(io, "This is in red\n"; color=:light_red)
printstyled(io, "This is in white(?)\n"; color=:normal)
end |
Why not? Colors can be very useful to improve the clarity of error messages.
I know how to work around it. I am saying that trying to color the whole exception message in red is just a bad idea because you don't know how the one that made the error message wants to format it. |
Encouraging the designers to customize the color of error messages spoils the simple rule of "red means error". |
That seems like an argument to make them better so that people will start reading them? The context this comes up in was when doing error messages for a TOML parser: compare that with Also, remember that the Julia error messages used to look like |
The expanded stacktrace printing introduced in #36134 and the fact that we no longer print errors in red (#36015) makes it harder to distinguish distinct exceptions in the stack. Add a newline for this, and print the "caused by" in red. Also remove exception numbering, which was arguably not very helpful.
The expanded stacktrace printing introduced in #36134 and the fact that we no longer print errors in red (#36015) makes it harder to distinguish distinct exceptions in the stack. Add a newline for this, and print the "caused by" in error_color(). Also remove exception numbering which was arguably not very helpful.
The expanded stacktrace printing introduced in #36134 and the fact that we no longer print errors in red (#36015) makes it harder to distinguish distinct exceptions in the stack. Add a newline for this, and print the "caused by" in error_color(). Also remove exception numbering which was arguably not very helpful.
The expanded stacktrace printing introduced in JuliaLang#36134 and the fact that we no longer print errors in red (JuliaLang#36015) makes it harder to distinguish distinct exceptions in the stack. Add a newline for this, and print the "caused by" in error_color(). Also remove exception numbering which was arguably not very helpful.
The code here
julia/base/errorshow.jl
Lines 87 to 95 in 0413ef0
tries its best to ensure that the
showerror
code an exception implement gets printed in red. This can mess up custom coloring that the exception itself tries to do inshowerror
. For example, here is some code that defines an exception text using colors:Trying with the normal two arg
showerror
and things look ok. But when the error would actually be shown in REPL, the second line would have "magically" also turned red, ruining the formatting.If an exception wants to print its text in red, it can just implement that with
printstyled
.The text was updated successfully, but these errors were encountered: