summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2010-04-30 20:06:11 -0500
committerJesse Luehrs <doy@tozt.net>2010-04-30 20:09:40 -0500
commitddd601047a76fb519d4acba4c59d77ebfde1fa6e (patch)
tree2a5840e61ce7a6868d522015ddc74c0f938d9be5 /lib
parentce489a3dcdcd8dcc1dec85b92698e0b94c85ca38 (diff)
downloadcarp-always-color-ddd601047a76fb519d4acba4c59d77ebfde1fa6e.tar.gz
carp-always-color-ddd601047a76fb519d4acba4c59d77ebfde1fa6e.zip
only color the actual warning/error
also clean up a couple more edge cases
Diffstat (limited to 'lib')
-rw-r--r--lib/Carp/Always/Color/HTML.pm11
-rw-r--r--lib/Carp/Always/Color/Term.pm11
2 files changed, 12 insertions, 10 deletions
diff --git a/lib/Carp/Always/Color/HTML.pm b/lib/Carp/Always/Color/HTML.pm
index 53b3f4e..e0cb599 100644
--- a/lib/Carp/Always/Color/HTML.pm
+++ b/lib/Carp/Always/Color/HTML.pm
@@ -23,20 +23,21 @@ STDERR is pointing to.
BEGIN { $Carp::Internal{(__PACKAGE__)}++ }
sub _die {
+ die @_ if ref($_[0]);
eval { Carp::Always::_die(@_) };
my $err = $@;
- $err =~ s/(.*)/<span style="color:#800">$1<\/span>/;
+ $err =~ s/(.*)( at .*? line .*?$)/<span style="color:#800">$1<\/span>$2/m;
die $err;
}
sub _warn {
- my $warning;
+ my @warning;
{
- local $SIG{__WARN__} = sub { $warning = $_[0] };
+ local $SIG{__WARN__} = sub { @warning = @_ };
Carp::Always::_warn(@_);
}
- $warning =~ s/(.*)/<span style="color:#880">$1<\/span>/;
- warn $warning;
+ $warning[0] =~ s/(.*)( at .*? line .*?$)/<span style="color:#880">$1<\/span>$2/m;
+ warn @warning;
}
my %OLD_SIG;
diff --git a/lib/Carp/Always/Color/Term.pm b/lib/Carp/Always/Color/Term.pm
index c4789f6..579eb5c 100644
--- a/lib/Carp/Always/Color/Term.pm
+++ b/lib/Carp/Always/Color/Term.pm
@@ -23,20 +23,21 @@ of where STDERR is pointing to.
BEGIN { $Carp::Internal{(__PACKAGE__)}++ }
sub _die {
+ die @_ if ref($_[0]);
eval { Carp::Always::_die(@_) };
my $err = $@;
- $err =~ s/(.*)/\e[31m$1\e[m/;
+ $err =~ s/(.*)( at .*? line .*?$)/\e[31m$1\e[m$2/m;
die $err;
}
sub _warn {
- my $warning;
+ my @warning;
{
- local $SIG{__WARN__} = sub { $warning = $_[0] };
+ local $SIG{__WARN__} = sub { @warning = @_ };
Carp::Always::_warn(@_);
}
- $warning =~ s/(.*)/\e[33m$1\e[m/;
- warn $warning;
+ $warning[0] =~ s/(.*)( at .*? line .*?$)/\e[33m$1\e[m$2/m;
+ warn @warning;
}
my %OLD_SIG;