Task.pm: ignore die() inside eval
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Sat, 7 Dec 2024 05:26:04 +0000 (06:26 +0100)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Sat, 7 Dec 2024 05:26:04 +0000 (06:26 +0100)
lib/Y/AoC/Task.pm

index cc1cdddd08a8346c21983d7ef79d268c6b55260b..0da7d2954ac540ecfa7818a9e36f7215021fef6f 100644 (file)
@@ -10,6 +10,9 @@ use Y::AoC qw(red white grey yellow day year);
 
 our $printed_err;
 $SIG{__DIE__} = sub($msg) {
+       if ($^S) {
+               die $@; # just rethrow
+       }
        $msg =~ s/\A(.*?)( at \S+ )(line \d+)/red($1).$2.white($3)/e
                if -t STDERR && !$printed_err++;
        say STDERR $msg;
@@ -29,6 +32,7 @@ our $in_test;
 sub t($subtest = ()) {
        $subtest //= '';
        $ARGV[0] =~ s/in\.txt/test$subtest.txt/ if defined $ARGV[0];
+       say STDERR grey("Test mode. Using "), white($ARGV[0]), grey(" instead.");
        $in_test = 1;
 }