blob: e0cb5991d45dc0049d8d300a03f96b8700505fa0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
package Carp::Always::Color::HTML;
use Carp::Always;
=head1 NAME
Carp::Always::Color::HTML - Carp::Always, but with HTML color
=head1 SYNOPSIS
use Carp::Always::Color::HTML;
or
perl -MCarp::Always::Color::HTML -e'sub foo { die "foo" } foo()'
=head1 DESCRIPTION
Like L<Carp::Always::Color>, but forces HTML coloring, regardless of where
STDERR is pointing to.
=cut
BEGIN { $Carp::Internal{(__PACKAGE__)}++ }
sub _die {
die @_ if ref($_[0]);
eval { Carp::Always::_die(@_) };
my $err = $@;
$err =~ s/(.*)( at .*? line .*?$)/<span style="color:#800">$1<\/span>$2/m;
die $err;
}
sub _warn {
my @warning;
{
local $SIG{__WARN__} = sub { @warning = @_ };
Carp::Always::_warn(@_);
}
$warning[0] =~ s/(.*)( at .*? line .*?$)/<span style="color:#880">$1<\/span>$2/m;
warn @warning;
}
my %OLD_SIG;
BEGIN {
@OLD_SIG{qw(__DIE__ __WARN__)} = @SIG{qw(__DIE__ __WARN__)};
$SIG{__DIE__} = \&_die;
$SIG{__WARN__} = \&_warn;
}
END {
@SIG{qw(__DIE__ __WARN__)} = @OLD_SIG{qw(__DIE__ __WARN__)};
}
=head1 AUTHOR
Jesse Luehrs <doy at tozt dot net>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Jesse Luehrs.
This is free software; you can redistribute it and/or modify it under
the same terms as perl itself.
=cut
1;
|