<commit_before>package SGN::View::Email::ErrorEmail;
use Moose;
use Moose::Util::TypeConstraints;

use Data::Dump ();
use Data::Visitor::Callback;

use Socket;

=head1 NAME

SGN::View::Email::ErrorEmail - Email View for SGN

=head1 DESCRIPTION

View for sending error emails from SGN.  Errors to email should be an
arrayref of strings in C<$c-E<gt>stash-E<gt>{email_errors}>.

=cut

BEGIN { extends 'SGN::View::Email' }

before 'process' => sub {
    my ($self, $c) = @_;

    # convert the notify_errors stash key into an email stash key for
    # the generic email view
    $c->stash->{email} = $self->make_email( $c );

    $c->log->debug('sending error email to '.$c->stash->{email}->{to}) if $c->debug;
};

=head1 ATTRIBUTES

=head2 debug_filter_visitor

The L<Data::Visitor::Callback> object being used for filtering.  Can
be replaced with your own L<Data::Visitor> subclass if desired.

=cut

has 'debug_filter_visitor' => (
    is => 'rw',
    isa => 'Data::Visitor',
    lazy_build => 1,
   );
sub _build_debug_filter_visitor {
    my ($self) = @_;

    return Data::Visitor::Callback->new(

        # descend into objects also
        object => 'visit_ref',

        # render skip_class option as visitor args
        ( map {
            my $class = $_;
            $class => sub { shift; '('.ref(shift)." object skipped, isa $class)" }
         } @{ $self->dump_skip_class }
        ),

        #render any other visitor args
        %{ $self->dump_visitor_args },

       );
}

=head2 dump_skip_class

One or more class names to filter out of objects to be dumped.  If an
object is-a one of these classes, the dump filtering will replace<commit_msg>tweak error email debug output filter<commit_after>package SGN::View::Email::ErrorEmail;
use Moose;
use Moose::Util::TypeConstraints;

use Data::Dump ();
use Data::Visitor::Callback;

use Socket;

=head1 NAME

SGN::View::Email::ErrorEmail - Email View for SGN

=head1 DESCRIPTION

View for sending error emails from SGN.  Errors to email should be an
arrayref of strings in C<$c-E<gt>stash-E<gt>{email_errors}>.

=cut

BEGIN { extends 'SGN::View::Email' }

before 'process' => sub {
    my ($self, $c) = @_;

    # convert the notify_errors stash key into an email stash key for
    # the generic email view
    $c->stash->{email} = $self->make_email( $c );

    $c->log->debug('sending error email to '.$c->stash->{email}->{to}) if $c->debug;
};

=head1 ATTRIBUTES

=head2 debug_filter_visitor

The L<Data::Visitor::Callback> object being used for filtering.  Can
be replaced with your own L<Data::Visitor> subclass if desired.

=cut

has 'debug_filter_visitor' => (
    is => 'rw',
    isa => 'Data::Visitor',
    lazy_build => 1,
   );
sub _build_debug_filter_visitor {
    my ($self) = @_;

    return Data::Visitor::Callback->new(

        # descend into objects also
        object               => 'visit_ref',
        ignore_return_values => 1,

        # render skip_class option as visitor args
        ( map {
            my $class = $_;
            $class => sub { shift; '('.ref(shift)." object skipped, isa $class)" }
         } @{ $self->dump_skip_class }
        ),

        #render any other visitor args
        %{ $self->dump_visitor_args },

       );
}

=head2 dump_skip_class

One or more class names to filter out of objects to be dumped.  If an
object is-a one of these classes, the dump filtering will replace
{'fraction_non_alphanumeric': 0.13107511045655376, 'fraction_numerical': 0.003829160530191458, 'mean_word_length': 3.12636695018226, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2468688', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1091, 'n_words': 342}