From ddd601047a76fb519d4acba4c59d77ebfde1fa6e Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 30 Apr 2010 20:06:11 -0500 Subject: only color the actual warning/error also clean up a couple more edge cases --- lib/Carp/Always/Color/Term.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/Carp/Always/Color/Term.pm') 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; -- cgit v1.2.3-54-g00ecf