1 package SGN
::View
::Email
::ErrorEmail
;
3 use Moose
::Util
::TypeConstraints
;
6 use Data
::Visitor
::Callback
;
10 SGN::View::Email::ErrorEmail - Email View for SGN
14 View for sending error emails from SGN.
18 BEGIN { extends
'SGN::View::Email' }
20 before
'process' => sub {
23 # convert the notify_errors stash key into an email stash key for
24 # the generic email view
25 $c->stash->{email
} = {
26 to
=> $self->default->{to
},
27 from
=> $self->default->{from
},
29 body
=> $self->_email_body( $c ),
32 $c->log->debug('sending error email to '.$c->stash->{email
}->{to
}) if $c->debug;
37 my ( $self, $c ) = @_;
42 "==== Error(s) ====\n\n",
43 ( map { $error_num++.". $_\n" } @
{$c->stash->{email_errors
}} ),
45 # all the necessary debug information
46 ( map { ("\n==== $_->[0] ====\n", $_->[1], "\n") } $self->dump_these_strings( $c ) );
52 =head2 debug_filter_visitor
54 The L<Data::Visitor::Callback> object being used for filtering. Can
55 be replaced with your own L<Data::Visitor> subclass if desired.
59 has
'debug_filter_visitor' => (
61 isa
=> 'Data::Visitor',
64 sub _build_debug_filter_visitor
{
67 return Data
::Visitor
::Callback
->new(
69 # descend into objects also
70 object
=> 'visit_ref',
72 # render skip_class option as visitor args
75 $class => sub { shift; '('.ref(shift)." object skipped, isa $class)" }
76 } @
{ $self->dump_skip_class }
79 #render any other visitor args
80 %{ $self->dump_visitor_args },
85 =head2 dump_skip_class
87 One or more class names to filter out of objects to be dumped. If an
88 object is-a one of these classes, the dump filtering will replace
89 the object with a string "skipped" message.
91 Can be either an arrayref or a whitespace-separated list of class names.
93 Default: "Catalyst", which will filter out Catalyst context objects.
95 =head2 dump_visitor_args
97 Hashref of additional constructor args passed to the
98 L<Data::Visitor::Callback> object used to filter the objects for
99 dumping. Can be used to introduce nearly any kind of additional
104 # replace all scalar values in dumped objects with "chicken"
107 value => sub { 'Chicken' },
113 { my $sc = subtype as
'ArrayRef';
114 coerce
$sc, from
'Str', via
{ [ split ] };
115 has
'dump_skip_class' => (
119 default => sub { ['Catalyst'] },
123 has
'dump_visitor_args' => (
126 default => sub { {} },
131 =head2 dump_these_strings( $c )
134 C<['Request', 'string dump'], ['Stash', 'string dump'], ...>
135 for use in debugging output.
139 sub dump_these_strings
{
142 map [ $_->[0], Data
::Dump
::dump( $self->filter_object_for_dump( $_->[1] ) ) ],
146 =head2 filter_object_for_dump( $object )
148 Return a filtered copy of the given object.
152 sub filter_object_for_dump
{
153 my ( $self, $object ) = @_;
154 $self->debug_filter_visitor->visit( $object );