in reply to Color die and warn messages

Hey, just silly thought I had regarding your "NOTE"

# NOTE: Doesn' play well with Carp::Always because it replaces our die

Since you are colorizing, instead of "die", use "dye" to prevent clobbering.

Otherwise, cool concept!

... I really hope Anonymous Monk gets this response ...

Replies are listed 'Best First'.
Re^2: Color die and warn messages
by Anonymous Monk on Sep 16, 2024 at 16:44 UTC
    Your quote is incomplete: "it replaces our die and warn sighandlers". The point of the code is to be drop-in and not require any other changes in your code. In fact, it would be better to call it in an eval so if it's not installed, it doesn't break anything: BEGIN { eval 'use warnings::colored' };.

    Changing die to dye would require you to change any code that uses it, and also it wouldn't then work on anything that internally called die or warn, like the example: system 'nonexistent-command'.

    If the %SIG entries could be tied variables, then it might be possible to make this play nice with Carp::Always. I haven't looked into that because it works fine enough as it is for me. That's why I released it anonymously and not to CPAN. If somebody wants to improve on it and deal with the edge cases, feel free to release it.