line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Engine::Middleware::DebugScreen; |
2
|
1
|
|
|
1
|
|
425
|
use HTTP::Engine::Middleware; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use HTTP::Engine::Response; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
3
|
use Scope::Upper qw( localize_elem :words ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
495
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has 'powerd_by' => ( |
9
|
|
|
|
|
|
|
is => 'rw', |
10
|
|
|
|
|
|
|
default => __PACKAGE__, |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'renderer' => ( |
14
|
|
|
|
|
|
|
is => 'rw', |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has 'err_info' => ( |
18
|
|
|
|
|
|
|
is => 'rw', |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'response' => ( |
22
|
|
|
|
|
|
|
is => 'rw', |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has 'stacktrace_required' => ( |
26
|
|
|
|
|
|
|
is => 'rw', |
27
|
|
|
|
|
|
|
isa => 'Bool', |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
before_handle { |
32
|
|
|
|
|
|
|
my($c, $self, $req) = @_; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$self->response(undef); |
35
|
|
|
|
|
|
|
$self->err_info(undef); |
36
|
|
|
|
|
|
|
$self->stacktrace_required(0); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
localize_elem '%SIG', '__DIE__' => sub { $c->diecatch(1); died($self, @_) } => SUB UP; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$req; |
41
|
|
|
|
|
|
|
}; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
after_handle { |
44
|
|
|
|
|
|
|
my($c, $self, $req, $res) = @_; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
if ($self->err_info) { |
47
|
|
|
|
|
|
|
$res = HTTP::Engine::Response->new; |
48
|
|
|
|
|
|
|
$res->code(500); |
49
|
|
|
|
|
|
|
$res->body( |
50
|
|
|
|
|
|
|
$self->err_info->as_html( |
51
|
|
|
|
|
|
|
powered_by => $self->powerd_by, |
52
|
|
|
|
|
|
|
($self->renderer ? (renderer => $self->renderer) : ()) |
53
|
|
|
|
|
|
|
) |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$res; |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
0
|
0
|
0
|
sub detach { die bless [@_], 'CGI::ExceptionManager::Exception' } |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub died { |
63
|
1
|
|
|
1
|
0
|
2
|
my($self, $msg) = @_; |
64
|
|
|
|
|
|
|
|
65
|
1
|
50
|
|
|
|
5
|
if (ref $msg eq 'CGI::ExceptionManager::Exception') { |
66
|
0
|
|
|
|
|
0
|
$self->response($msg->[0]); |
67
|
0
|
|
|
|
|
0
|
$self->err_info(undef); |
68
|
|
|
|
|
|
|
} else { |
69
|
1
|
50
|
|
|
|
5
|
unless ($self->stacktrace_required) { |
70
|
1
|
|
|
|
|
454
|
require CGI::ExceptionManager::StackTrace; |
71
|
1
|
|
|
|
|
604
|
$self->stacktrace_required(1); |
72
|
|
|
|
|
|
|
} |
73
|
1
|
|
|
|
|
5
|
$self->err_info( CGI::ExceptionManager::StackTrace->new($msg) ); |
74
|
|
|
|
|
|
|
} |
75
|
1
|
|
|
|
|
91
|
die $msg; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__MIDDLEWARE__ |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 NAME |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
HTTP::Engine::Middleware::DebugScreen - dump stack-trace when die |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SYNOPSIS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $mw = HTTP::Engine::Middleware->new; |
89
|
|
|
|
|
|
|
$mw->install(qw/ HTTP::Engine::Middleware::DebugScreen /); |
90
|
|
|
|
|
|
|
HTTP::Engine->new( |
91
|
|
|
|
|
|
|
interface => { |
92
|
|
|
|
|
|
|
module => 'YourFavoriteInterfaceHere', |
93
|
|
|
|
|
|
|
request_handler => $mw->handler( \&handler ), |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
)->run(); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 AUTHORS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
yappo |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
kan |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
and more? |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SEE ALSO |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L<Scope::Upper>, L<CGI::ExceptionManager::StackTrace> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |