line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kossy::Exception; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
24
|
use strict; |
|
7
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
153
|
|
4
|
7
|
|
|
7
|
|
22
|
use warnings; |
|
7
|
|
|
|
|
6
|
|
|
7
|
|
|
|
|
131
|
|
5
|
7
|
|
|
7
|
|
2990
|
use HTTP::Status; |
|
7
|
|
|
|
|
19358
|
|
|
7
|
|
|
|
|
1260
|
|
6
|
7
|
|
|
7
|
|
32
|
use Text::Xslate qw/html_escape/; |
|
7
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
275
|
|
7
|
7
|
|
|
7
|
|
2086
|
use Kossy::Response; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
1516
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.40'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
4
|
|
|
4
|
0
|
4
|
my $class = shift; |
13
|
4
|
|
|
|
|
3
|
my $code = shift; |
14
|
4
|
|
|
|
|
7
|
my %args = ( |
15
|
|
|
|
|
|
|
code => $code, |
16
|
|
|
|
|
|
|
); |
17
|
4
|
50
|
|
|
|
13
|
if ( @_ == 1 ) { |
|
|
50
|
|
|
|
|
|
18
|
0
|
|
|
|
|
0
|
$args{message} = shift; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
elsif ( @_ % 2 == 0) { |
21
|
4
|
|
|
|
|
11
|
%args = ( |
22
|
|
|
|
|
|
|
%args, |
23
|
|
|
|
|
|
|
@_ |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
} |
26
|
4
|
|
|
|
|
22
|
bless \%args, $class; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub response { |
30
|
4
|
|
|
4
|
0
|
5
|
my $self = shift; |
31
|
4
|
|
50
|
|
|
12
|
my $code = $self->{code} || 500; |
32
|
4
|
|
|
|
|
6
|
my $message = $self->{message}; |
33
|
4
|
|
33
|
|
|
12
|
$message ||= HTTP::Status::status_message($code); |
34
|
|
|
|
|
|
|
|
35
|
4
|
|
|
|
|
17
|
my @headers = ( |
36
|
|
|
|
|
|
|
'Content-Type' => q!text/html; charset=UTF-8!, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
4
|
50
|
33
|
|
|
10
|
if ($code =~ /^3/ && (my $loc = eval { $self->{location} })) { |
|
0
|
|
|
|
|
0
|
|
40
|
0
|
|
|
|
|
0
|
push(@headers, Location => $loc); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
4
|
|
|
|
|
10
|
return Kossy::Response->new($code, \@headers, [$self->html($code,$message)])->finalize; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub html { |
47
|
4
|
|
|
4
|
0
|
4
|
my $self = shift; |
48
|
4
|
|
|
|
|
5
|
my ($code,$message) = @_; |
49
|
4
|
|
|
|
|
30
|
$code = html_escape($code); |
50
|
4
|
|
|
|
|
9
|
$message = html_escape($message); |
51
|
4
|
|
|
|
|
52
|
return <
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$code $message |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
EOF |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |