p6-HTTP-Server-Tiny icon indicating copy to clipboard operation
p6-HTTP-Server-Tiny copied to clipboard

Color on errors

Open dataf3l opened this issue 9 years ago • 3 comments

When I make msitakes on my code, inside the HTTP SERVER TINY "servlet" code, I see Perl6 prints "===== SORRY! =====" which usually has colors, but within the context of HTTP::Server::Tiny doesn't have any color. I'd like colors in the output, can this be enabled by default?

dataf3l avatar Nov 19 '16 03:11 dataf3l

Hi, the ==== SORRY! ===== messages are compile time errors and the colours are generated in the .gist of the exception by rakudo itself. If the exception is caught and the exception is interpolated into a string (as it is here,) the .Str method of the Exception is used instead which doesn't have the ==== SORRY! =====' nor the colours (and has less detail around the context and so forth,) this is intentional in the design of the exceptions (and infact all of perl 6 - if you pass say a non-string object it will call its .gist method )

So the module isn't doing anything particular to remove the colours but rather it is just the way that the presentation of the exceptions works in general.

jonathanstowe avatar Nov 19 '16 11:11 jonathanstowe

I guess my problem is that it's hard for me to tell apart the error message from the rest of the program output when Using HTTP::Server::Tiny, since it's all in the same color:

this is a typical error message:

[ERROR] [82112] [15] No such method 'ac_duck' for invocant of type 'usr_controller::Usr' in method throw at gen/moar/m-CORE.setting line 24539 in sub at gen/moar/m-CORE.setting line 26868 in method dispatch at /Users/a/Desktop/ab/htdocs/gis/backend2/Route.pm6 (Route) line 57 in sub at serve3.p6 line 86 in sub at /usr/local/Cellar/rakudo-star/2016.10/share/perl6/site/sources/41D120CC8C5AC1ADBAA2CC7E606E4F8710D84044 (HTTP::Server::Tiny) line 254 in method run-app at /usr/local/Cellar/rakudo-star/2016.10/share/perl6/site/sources/41D120CC8C5AC1ADBAA2CC7E606E4F8710D84044 (HTTP::Server::Tiny) line 247 in block at /usr/local/Cellar/rakudo-star/2016.10/share/perl6/site/sources/41D120CC8C5AC1ADBAA2CC7E606E4F8710D84044 (HTTP::Server::Tiny) line 224 in method parse-body at /usr/local/Cellar/rakudo-star/2016.10/share/perl6/site/sources/41D120CC8C5AC1ADBAA2CC7E606E4F8710D84044 (HTTP::Server::Tiny) line 172 in method handle at /usr/local/Cellar/rakudo-star/2016.10/share/perl6/site/sources/41D120CC8C5AC1ADBAA2CC7E606E4F8710D84044 (HTTP::Server::Tiny) line 89 in block at /usr/local/Cellar/rakudo-star/2016.10/share/perl6/site/sources/41D120CC8C5AC1ADBAA2CC7E606E4F8710D84044 (HTTP::Server::Tiny) line 534 in block at gen/moar/m-CORE.setting line 36567 in block at gen/moar/m-CORE.setting line 36538 in method protect at gen/moar/m-CORE.setting line 35623 in block at gen/moar/m-CORE.setting line 36538 in block at gen/moar/m-CORE.setting line 37782 in method emit at gen/moar/m-CORE.setting line 37779 in method emit at gen/moar/m-CORE.setting line 37819 in block at gen/moar/m-CORE.setting line 38432 in method emit-events at gen/moar/m-CORE.setting line 3492 in block at gen/moar/m-CORE.setting line 3480 in block at gen/moar/m-CORE.setting line 3475 in method protect at gen/moar/m-CORE.setting line 35625 in method process at gen/moar/m-CORE.setting line 3472 in block at gen/moar/m-CORE.setting line 38435 in block at gen/moar/m-CORE.setting line 35773 in block at gen/moar/m-CORE.setting line 35770 in block at gen/moar/m-CORE.setting line 35769 in block at gen/moar/m-CORE.setting line 35766

I think color would help make this error message more awesome... Perhaps by highlighting the relevant error text: I don't really understand what the error numbers mean "[ERROR] [82112] [15]", this error is too cryptic, and I think color or some line breaks would help. I also don't understand why is my error on my code reported on

in method throw at gen/moar/m-CORE.setting line 24539 in sub at gen/moar/m-CORE.setting line 26868

I don't see how those lines relate to my program, or why they are at the top of the StackTrace, I'm confused by the output, this generates anxiety.

Maybe color can help?

dataf3l avatar Nov 20 '16 18:11 dataf3l

Hi, I'd like to know if this issue was addressed...

dataf3l avatar Oct 24 '20 06:10 dataf3l