| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catalyst::Action::RenderView::ErrorHandler::Action::Email; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
26580
|
use 5.010001; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
34
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
41
|
|
|
6
|
1
|
|
|
1
|
|
493
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Catalyst::Action::RenderView::ErrorHandler::Action'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'options' => (is => 'rw', isa => 'HashRef', default => sub { [] }); |
|
13
|
|
|
|
|
|
|
has 'view' => (is => 'ro', isa => 'Str'); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub perform { |
|
16
|
|
|
|
|
|
|
my $self = shift; |
|
17
|
|
|
|
|
|
|
my $c = shift; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#Add defined options field to catalyst stash |
|
20
|
|
|
|
|
|
|
foreach my $key (keys %{$self->{options}}) { |
|
21
|
|
|
|
|
|
|
$c->stash->{email}->{$key} = $self |
|
22
|
|
|
|
|
|
|
->{options}->{$key}; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$c->forward( $c->view($self->view) ); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
|
29
|
|
|
|
|
|
|
__END__ |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 NAME |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Catalyst::Action::RenderView::ErrorHandler::Action::Email - Catalyst ErrorHandler Action for Email |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#In a configuration somewhere: |
|
38
|
|
|
|
|
|
|
error_handler => { |
|
39
|
|
|
|
|
|
|
'actions' => [ |
|
40
|
|
|
|
|
|
|
{ |
|
41
|
|
|
|
|
|
|
type => 'Log', |
|
42
|
|
|
|
|
|
|
id => 'log-server', |
|
43
|
|
|
|
|
|
|
level => 'error' |
|
44
|
|
|
|
|
|
|
}, |
|
45
|
|
|
|
|
|
|
{ |
|
46
|
|
|
|
|
|
|
#Use this action |
|
47
|
|
|
|
|
|
|
type => 'Email', |
|
48
|
|
|
|
|
|
|
id => 'log-email', |
|
49
|
|
|
|
|
|
|
#Regex to ignore all request paths with PhpMyAdmin or SqlDump init. Regex is case insensitive used. |
|
50
|
|
|
|
|
|
|
ignorePath => '(PhpMyAdmin|SqlDump)', |
|
51
|
|
|
|
|
|
|
#This should be a Catalyst::View::Email::Template or Catalyst::View::Email view. |
|
52
|
|
|
|
|
|
|
view => 'ErrorMail', |
|
53
|
|
|
|
|
|
|
#This options are copied into $c->stash->{email} for accesing from the view selected above |
|
54
|
|
|
|
|
|
|
#For additional information look into the documentation of Catalyst::View::Email::Template |
|
55
|
|
|
|
|
|
|
options => { |
|
56
|
|
|
|
|
|
|
( |
|
57
|
|
|
|
|
|
|
#becomes $c->stash->{email}->{from} = ... |
|
58
|
|
|
|
|
|
|
from => 'MyApp - Homepage <homepage@domain.com>', |
|
59
|
|
|
|
|
|
|
to => 'you@domain.com', |
|
60
|
|
|
|
|
|
|
subject => 'Homepage - ErrorMail', |
|
61
|
|
|
|
|
|
|
#Template isn't needed, if you use the simple Catalyst::View::Email |
|
62
|
|
|
|
|
|
|
templates => [ |
|
63
|
|
|
|
|
|
|
{ |
|
64
|
|
|
|
|
|
|
template => 'ErrorMail.tt2', |
|
65
|
|
|
|
|
|
|
content_type => 'text/html', |
|
66
|
|
|
|
|
|
|
charset => 'utf-8', |
|
67
|
|
|
|
|
|
|
encoding => 'quoted-printable', |
|
68
|
|
|
|
|
|
|
#View to render the Template |
|
69
|
|
|
|
|
|
|
view => 'HTMLEmail', |
|
70
|
|
|
|
|
|
|
}, |
|
71
|
|
|
|
|
|
|
] |
|
72
|
|
|
|
|
|
|
)} |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
], |
|
75
|
|
|
|
|
|
|
'handlers' => { |
|
76
|
|
|
|
|
|
|
( |
|
77
|
|
|
|
|
|
|
'5xx' => { |
|
78
|
|
|
|
|
|
|
template => 'error_internal.tt2', |
|
79
|
|
|
|
|
|
|
actions => ['log-server','log-email'] |
|
80
|
|
|
|
|
|
|
}, |
|
81
|
|
|
|
|
|
|
'404' => { |
|
82
|
|
|
|
|
|
|
template => 'error.tt2' |
|
83
|
|
|
|
|
|
|
}, |
|
84
|
|
|
|
|
|
|
'fallback' => { |
|
85
|
|
|
|
|
|
|
static => 'root/src/error.html', |
|
86
|
|
|
|
|
|
|
actions => ['log-email','log-email'] |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
)} |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#The template may look like: |
|
92
|
|
|
|
|
|
|
[% USE Dumper %] |
|
93
|
|
|
|
|
|
|
<!DOCTYPE html> |
|
94
|
|
|
|
|
|
|
<head> |
|
95
|
|
|
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|
96
|
|
|
|
|
|
|
<title>Error Report</title> |
|
97
|
|
|
|
|
|
|
</head> |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
<body> |
|
100
|
|
|
|
|
|
|
<p>There was a error in yor App:</p> |
|
101
|
|
|
|
|
|
|
<h4>Requested path:</h4> |
|
102
|
|
|
|
|
|
|
<p>[% base %][% c.request.path %]</p> |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
<h4>Arguments:</h4> |
|
105
|
|
|
|
|
|
|
[% FOREACH a IN c.request.args %] |
|
106
|
|
|
|
|
|
|
<p>[% a | html %]</p> |
|
107
|
|
|
|
|
|
|
[% END %] |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
<h4>Parameters:</h4> |
|
110
|
|
|
|
|
|
|
[% Dumper.dump(c.request.parameters) %] |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
<h4>User Agent:</h4> |
|
113
|
|
|
|
|
|
|
<p>[% c.request.user_agent | html %]</p> |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
<h4>Referer:</h4> |
|
116
|
|
|
|
|
|
|
<p>[% c.request.referer | html %]</p> |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
<h4>Error messages:</h4> |
|
119
|
|
|
|
|
|
|
[% FOREACH e IN c.error %] |
|
120
|
|
|
|
|
|
|
<p>[% e | html %]</p> |
|
121
|
|
|
|
|
|
|
[% END %] |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
[% IF c.response.code %] |
|
124
|
|
|
|
|
|
|
<h4>Error code:</h4> |
|
125
|
|
|
|
|
|
|
<p>[% c.response.code %]</p> |
|
126
|
|
|
|
|
|
|
[% END %] |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
</body> |
|
129
|
|
|
|
|
|
|
</html> |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Used by L<Catalyst::Action::RenderView::ErrorHandler> to send an Email if there |
|
135
|
|
|
|
|
|
|
is an error in your Catalyst application. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
L<Catalyst::Action::RenderView::ErrorHandler> |
|
140
|
|
|
|
|
|
|
L<Catalyst::Action::RenderView::ErrorHandler::Action::Log> |
|
141
|
|
|
|
|
|
|
L<Catalyst::View::Email> |
|
142
|
|
|
|
|
|
|
L<Catalyst::View::Email::Template> |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 AUTHOR |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Stefan Profanter, E<lt>profanter@cpan.orgE<gt> |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Copyright (C) 2011 by Stefan Profanter |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
153
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.10.1 or, |
|
154
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |