line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Moose; |
3
|
1
|
|
|
1
|
|
1102
|
use Text::Template; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
4
|
1
|
|
|
1
|
|
5291
|
use CatalystX::Utils::ContentNegotiation; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
78
|
|
5
|
1
|
|
|
1
|
|
6
|
use CatalystX::Utils::ErrorMessages; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
6
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
368
|
|
7
|
|
|
|
|
|
|
extends 'Catalyst::View'; |
8
|
|
|
|
|
|
|
with 'Catalyst::Component::ApplicationAttribute'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has template_engine_args => ( |
11
|
|
|
|
|
|
|
is=>'ro', |
12
|
|
|
|
|
|
|
required=>1, |
13
|
|
|
|
|
|
|
lazy=>1, |
14
|
|
|
|
|
|
|
default=> sub { |
15
|
|
|
|
|
|
|
my $self = shift; |
16
|
|
|
|
|
|
|
my $template = $self->_application->config->{root}->file($self->template_name); |
17
|
|
|
|
|
|
|
my $source = -e $template ? $template->slurp : $self->text($self->_application); |
18
|
|
|
|
|
|
|
return +{TYPE => 'STRING', SOURCE => $source}; |
19
|
|
|
|
|
|
|
}, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has template_name => (is=>'ro', required=>1, default=>'http_errors_text.tmpl'); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my ($self, $app) = @_; |
25
|
|
|
|
|
|
|
return q[{$status_code} {$title}:{$message}]."\n"; |
26
|
0
|
|
|
0
|
1
|
|
} |
27
|
0
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has template_engine => ( |
29
|
|
|
|
|
|
|
is => 'ro', |
30
|
|
|
|
|
|
|
required => 1, |
31
|
|
|
|
|
|
|
init_arg => undef, |
32
|
|
|
|
|
|
|
lazy => 1, |
33
|
|
|
|
|
|
|
default => sub { |
34
|
|
|
|
|
|
|
my %args = %{shift->template_engine_args}; |
35
|
|
|
|
|
|
|
my $engine = Text::Template->new(%args); |
36
|
|
|
|
|
|
|
$engine->compile; |
37
|
|
|
|
|
|
|
return $engine; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my ($self, $c, $code, %args) = @_; |
42
|
|
|
|
|
|
|
my $text = $self->render_template($c, \%args); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
0
|
0
|
|
$c->response->body($text); |
45
|
0
|
|
|
|
|
|
$c->response->content_type('text/plain'); |
46
|
|
|
|
|
|
|
$c->response->status($code); |
47
|
0
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my ($self, $c, $message_info) = @_; |
50
|
|
|
|
|
|
|
return my $text = $self->template_engine->fill_in(HASH => $message_info); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
0
|
0
|
|
__PACKAGE__->meta->make_immutable; |
54
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Catalyst::View::Errors::Text - Standard HTTP Errors Responses in Plain Text. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 SYNOPSIS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
package MyApp::View::Text; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
use Moose; |
64
|
|
|
|
|
|
|
extends 'Catalyst::View::Errors::Text'; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 DESCRIPTION |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
View class for generating error responses. If you want a lot of customizations you can subclass |
71
|
|
|
|
|
|
|
this in your application, or just use your own view. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 METHODS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This view exposes the follow methods for public use or for a programmer to override |
76
|
|
|
|
|
|
|
to change function. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
The follow field arguments are passed to this template: |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=over 4 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item lang |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Defaults to "en_US". This is the language code of the error response. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item message |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This is a text message of the error condition |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item status_code |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This is the HTTP Status code of the error |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item title |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
The official HTTP Status error title (Not Found, Not Authorized, etc.) |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item uri |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
The URI that generated the error. Be careful displaying this in your template since if its not |
101
|
|
|
|
|
|
|
properly escaped you can open yourself to HTML injection / Javascript injection attackes. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=back |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
In addition any other arguments passed in ->dispatch_error / ->detach_error. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 text |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Should return a string suitable for L<Text::Template> and is used to generate |
110
|
|
|
|
|
|
|
a plain text error response. This is used if there's no file at C<$APPHOME/root/http_errors_text.tmpl> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 CONFIGURATION |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This View exposes the following configuration options |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 template_engine_args |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Args that are used to start the L<Text::Template> template engin |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 template_name |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Name of the files under $APPHOME/root that is used to render an error view. |
123
|
|
|
|
|
|
|
Default is C<http_errors_text.tmpl>. If this this file doesn't exist we |
124
|
|
|
|
|
|
|
instead use the return of L</text> method for the template string. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 SEE ALSO |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
L<CatalystX::Errors>. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 AUTHOR |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
L<CatalystX::Errors>. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
L<CatalystX::Errors>. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |