| 1 | package Plack::Middleware::DiePretty; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use parent 'Plack::Middleware'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Plack::Util::Accessor qw(template); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Template; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Path::Class; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use FindBin qw($Bin); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | sub call { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
call: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | my ($self, $env) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | ▶ | local $SIG{__DIE__} = sub { die @_; }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | my $caught; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | ▶ | my $res = try { $self->app->($env); } catch { $caught = $_; [ 500, [ 'Content-Type' => 'text/plain; charset=utf-8' ], [ $caught ] ]; }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | ▶ | my $template = file( $self->template || "$Bin/html/error.html" ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->template || "$Plack::Middleware::DiePretty::Bin/html/error.html"
MC/DC100%1/1
$self->template || "$Plack::Middleware::DiePretty::Bin/html/error.html"
$self->template
Truth table100%2/2
A
A= $self->template
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | ▶ | if ($caught || (ref $res eq 'ARRAY' && $res->[0] == 500)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$caught or ref $res eq "ARRAY" and $res->[0] == 500
ref $res eq "ARRAY" and $res->[0] == 500
MC/DC33%1/3
$caught or ref $res eq "ARRAY" and $res->[0] == 500
$caught
ref $res eq "ARRAY"
$res->[0] == 500
Truth table50%2/4
A or B and C
A= $caughtB= ref $res eq "ARRAY"C= $res->[0] == 500
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | Template->new({ INCLUDE_PATH => $template->dir->absolute })->process($template->basename, { caught => $caught }, \(my $html)) || die $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | $res = [ 500, [ 'Content-Type' => 'text/html'], [ $html ] ]; | |||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | $res; | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | __END__ | ||||||||||||||||||||||||||||||||||||||||||