Mojolicious-Plugin-MailException-0.24/0000755000175000017500000000000013316653152016741 5ustar unerauneraMojolicious-Plugin-MailException-0.24/lib/0000755000175000017500000000000013316653152017507 5ustar unerauneraMojolicious-Plugin-MailException-0.24/lib/Mojolicious/0000755000175000017500000000000013316653152022003 5ustar unerauneraMojolicious-Plugin-MailException-0.24/lib/Mojolicious/Plugin/0000755000175000017500000000000013316653152023241 5ustar unerauneraMojolicious-Plugin-MailException-0.24/lib/Mojolicious/Plugin/MailException.pm0000644000175000017500000001771613316652677026367 0ustar uneraunera=head1 NAME Mojolicious::Plugin::MailException - Mojolicious plugin to send crash information by email =head1 SYNOPSIS package MyServer; use Mojo::Base 'Mojolicious'; sub startup { my ($self) = @_; $self->plugin(MailException => { from => 'robot@my.site.com', to => 'mail1@my.domain.com, mail2@his.domain.com', subject => 'My site crashed!', headers => { 'X-MySite' => 'crashed' }, stack => 10 }); } =head1 DESCRIPTION The plugin catches all exceptions, packs them into email and sends them to email. There are some plugin options: =over =item from From-address for email (default B) =item to To-address(es) for email (default B) =item subject Subject for crash email =item headers Hash with headers that have to be added to mail =item stack Stack size for crash mail. Default is C<20>. =item maildir This option saves (stores) messages in the maildir instead of sending them. If you catch too many crashes, then their sending probably uses too much of the CPU, so by using this option you may save your messages instead of sending them. The option is ignored if C option is defined. =item send Subroutine that can be used to send the mail, example: sub startup { my ($self) = @_; $self->plugin(MailException => { send => sub { my ($mail, $exception) = @_; $mail->send; # prepared MIME::Lite object } }); } In the function You can send email by yourself and (or) prepare and send Your own mail (sms, etc) message using B<$exception> object. See L. =back The plugin provides additional method (helper) B. $cx->mail_exception('my_error', { 'X-Add-Header' => 'value' }); You can use the helper to raise exception with additional mail headers. =head1 VCS The plugin is placed on L. =head1 COPYRIGHT AND LICENCE Copyright (C) 2012 by Dmitry E. Oboukhov Copyright (C) 2012 by Roman V. Nikolaev This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. =cut package Mojolicious::Plugin::MailException; our $VERSION = '0.24'; use 5.008008; use strict; use warnings; use Mojo::Base 'Mojolicious::Plugin'; use Data::Dumper; use Mojo::Exception; use Carp; use MIME::Lite; use MIME::Words ':all'; use File::Spec::Functions 'rel2abs', 'catfile'; my $mail_prepare = sub { my ($e, $conf, $self, $from, $to, $headers, $stack_depth) = @_; my $subject = $conf->{subject} || 'Caught exception'; $subject .= ' (' . $self->req->method . ': ' . $self->req->url->to_abs->to_string . ')'; utf8::encode($subject) if utf8::is_utf8 $subject; $subject = encode_mimeword $subject, 'B', 'utf-8'; my $text = ''; $text .= "Exception\n"; $text .= "~~~~~~~~~\n"; $text .= $e->message; $text .= "\n"; my $maxl = eval { length $e->lines_after->[-1][0]; }; $maxl ||= 5; $text .= sprintf " %*d %s\n", $maxl, @{$_}[0,1] for @{ $e->lines_before }; $text .= sprintf " * %*d %s\n", $maxl, @{ $e->line }[0,1] if $e->line->[0]; $text .= sprintf " %*d %s\n", $maxl, @{$_}[0,1] for @{ $e->lines_after }; if (@{ $e->frames }) { my $no = 0; $text .= "\n"; $text .= "Stack\n"; $text .= "~~~~~\n"; for (@{ $e->frames }) { $no++; if ($no > $stack_depth) { $text .= " ...\n"; last; } $text .= sprintf " %s: %d\n", @{$_}[1,2]; } } if (eval { $self->session; scalar keys %{ $self->session } }) { local $Data::Dumper::Indent = 1; local $Data::Dumper::Terse = 1; local $Data::Dumper::Useqq = 1; local $Data::Dumper::Deepcopy = 1; local $Data::Dumper::Maxdepth = 0; $text .= "\n"; $text .= "Session\n"; $text .= "~~~~~~~\n"; $text .= Dumper($self->session); } eval { utf8::encode($text) if utf8::is_utf8 $text }; my $mail = MIME::Lite->new( From => $from, To => $to, Subject => $subject, Type => 'multipart/mixed', ); $mail->attach( Type => 'text/plain; charset=utf-8', Data => $text ); $text = "Request\n"; $text .= "~~~~~~~\n"; my $req = $self->req->to_string; $req =~ s/^/ /gm; $text .= $req; $mail->attach( Type => 'text/plain; charset=utf-8', Filename => 'request.txt', Disposition => 'inline', Data => $text ); $mail->add($_ => $headers->{$_}) for keys %$headers; return $mail; }; use Fcntl; my $store_maildir = sub { my ($dir, $mail) = @_; unless (-x $dir and -d $dir and -w $dir) { warn "Directory `$dir' does not exists or accessible\n"; return; } my $now = time; for (my $i = 0; $i < 1000; $i++) { my $fname = catfile $dir, sprintf '%d.%05d', $now, $i; my $fh; if (sysopen $fh, $fname, O_CREAT | O_WRONLY) { binmode $fh => ':raw'; my $str = $mail->as_string; if (utf8::is_utf8 $str) { utf8::encode $str; } print $fh $str; close $fh; last; } } }; sub register { my ($self, $app, $conf) = @_; my $stack_depth = $conf->{stack} || 20; my $cb = $conf->{send}; unless ('CODE' eq ref $cb) { $cb = sub { $_[0]->send }; if (my $dir = $conf->{maildir}) { warn "Directory `$dir' does not exists or accessible" unless -x $dir and -d $dir and -w $dir; $dir = rel2abs $dir; $cb = sub { $store_maildir->($dir, shift) }; } } croak "Usage: app->plugin('ExceptionMail'[, send => sub { ... })'" unless 'CODE' eq ref $cb; my $headers = $conf->{headers} || {}; my $from = $conf->{from} || 'root@localhost'; my $to = $conf->{to} || 'webmaster@localhost'; croak "headers must be a HASHREF" unless 'HASH' eq ref $headers; $app->hook(around_dispatch => sub { my ($next, $c) = @_; my $e; { local $SIG{__DIE__} = sub { ($e) = @_; unless (ref $e and $e->isa('Mojo::Exception')) { my @caller = caller; $e =~ s/at\s+(.+?)\s+line\s+(\d+).*//s; $e = Mojo::Exception->new( sprintf "%s at %s line %d\n", "$e", @caller[1,2] ); $e->trace(1); $e->inspect if $e->can('inspect'); } CORE::die $e; }; eval { $next->() }; } return unless $@; unless ($e) { $e = Mojo::Exception->new($@); $e->trace(1); $e->inspect if $e->can('inspect'); } my $hdrs = $headers; $hdrs = { %$hdrs, %{ $e->{local_headers} } } if ref $e->{local_headers}; my $mail = $mail_prepare->( $e, $conf, $c, $from, $to, $hdrs, $stack_depth ); eval { local $SIG{CHLD} = 'IGNORE'; local $SIG{__DIE__}; $cb->($mail, $e); 1; } or warn $@; # propagate Mojo::Exception die $e; }); $app->helper(mail_exception => sub { my ($self, $et, $hdrs) = @_; my @caller = caller 1; $et ||= 'exception'; my $e = Mojo::Exception->new( sprintf '%s at %s line %d', $et, @caller[1,2] ); $e->trace(2); $e->inspect if $e->can('inspect'); $e->{local_headers} = $hdrs; CORE::die $e; }); } 1; Mojolicious-Plugin-MailException-0.24/debian/0000755000175000017500000000000013316653152020163 5ustar unerauneraMojolicious-Plugin-MailException-0.24/debian/watch0000644000175000017500000000023513316632153021212 0ustar unerauneraversion=3 http://search.cpan.org/dist/Mojolicious-Plugin-MailException/ .*/Mojolicious-Plugin-MailException-v?(\d[\d.-]+)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip)$ Mojolicious-Plugin-MailException-0.24/debian/copyright0000644000175000017500000000200313316632153022107 0ustar unerauneraFormat-Specification: http://anonscm.debian.org/viewvc/dep/web/deps/dep5.mdwn?view=markup&pathrev=135 Maintainer: (information incomplete) Source: http://search.cpan.org/dist/Mojolicious-Plugin-MailException/ Name: Mojolicious-Plugin-MailException Files: * Copyright: 2012, Dmitry E. Oboukhov 2012, Roman V. Nikolaev License: Artistic This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License, which comes with Perl. . On Debian systems, the complete text of the Artistic License can be found in `/usr/share/common-licenses/Artistic'. License: GPL-1+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. . On Debian systems, the complete text of version 1 of the GNU General Public License can be found in `/usr/share/common-licenses/GPL-1'. Mojolicious-Plugin-MailException-0.24/debian/changelog0000644000175000017500000001245513316653031022040 0ustar unerauneralibmojolicious-plugin-mailexception-perl (0.24-1) unstable; urgency=medium * Do not croak if maildir is not accessible. -- Dmitry E. Oboukhov Tue, 03 Jul 2018 13:52:36 +0300 libmojolicious-plugin-mailexception-perl (0.23-1) nowtaxi; urgency=medium * Update version. Prevent hangs up if someone remove maildir. -- Dmitry E. Oboukhov Tue, 03 Jul 2018 12:17:14 +0300 libmojolicious-plugin-mailexception-perl (0.22-1) nowtaxi; urgency=medium * Add 'maildir' configoption. -- Dmitry E. Oboukhov Tue, 03 Jul 2018 12:09:32 +0300 libmojolicious-plugin-mailexception-perl (0.21-1) nowtaxi; urgency=medium * Stacksize limit. -- Dmitry E. Oboukhov Wed, 04 Apr 2018 16:53:52 +0300 libmojolicious-plugin-mailexception-perl (0.20-1) unstable; urgency=medium * Update for latest mojolicious, Debian FTBFS, closes: 825541. -- Dmitry E. Oboukhov Sun, 05 Jun 2016 13:33:41 +0300 libmojolicious-plugin-mailexception-perl (0.19-1) unstable; urgency=medium * Some fixes for Mojo v.5, closes: #765004 thanks to Stephan Jauernick . -- Dmitry E. Oboukhov Fri, 17 Oct 2014 23:44:06 +0400 libmojolicious-plugin-mailexception-perl (0.18-1) unstable; urgency=low * User can add different tags for exceptions. -- Dmitry E. Oboukhov Wed, 06 Nov 2013 11:29:05 +0400 libmojolicious-plugin-mailexception-perl (0.17-1) unstable; urgency=low * New release, closes: #713231 - New Mojo uses render(text => $text) instead reder_text($text). -- Dmitry E. Oboukhov Sat, 17 Aug 2013 12:09:17 +0400 libmojolicious-plugin-mailexception-perl (0.16-1) unstable; urgency=low * Works properly if client's application redefines $SIG{__DIE__}, too. -- Dmitry E. Oboukhov Sun, 24 Mar 2013 00:24:49 +0400 libmojolicious-plugin-mailexception-perl (0.15-1) unstable; urgency=low * use CORE::die instead die (try to localize modperl's segfaults). -- Dmitry E. Oboukhov Wed, 20 Mar 2013 02:30:07 +0400 libmojolicious-plugin-mailexception-perl (0.14-1) unstable; urgency=low * Plugin doesn't catch transitional exceptions. -- Dmitry E. Oboukhov Tue, 19 Mar 2013 17:44:25 +0400 libmojolicious-plugin-mailexception-perl (0.12-1) unstable; urgency=low * $SIG{__DIE__} doesn't modify original exception. -- Dmitry E. Oboukhov Thu, 14 Mar 2013 02:47:37 +0400 libmojolicious-plugin-mailexception-perl (0.11-2) unstable; urgency=low * Add Roman V. Nikolaev to uploaders list. * Upload last fixes into Debian. -- Dmitry E. Oboukhov Sun, 10 Feb 2013 22:36:04 +0400 libmojolicious-plugin-mailexception-perl (0.11-1) nowtaxi; urgency=low * Don`t catch eval exception. -- Roman V. Nikolaev Sat, 09 Feb 2013 15:27:40 +0400 libmojolicious-plugin-mailexception-perl (0.10-1) nowtaxi; urgency=low * Fix exception catching if exception is object. -- Roman V. Nikolaev Sat, 09 Feb 2013 15:16:22 +0400 libmojolicious-plugin-mailexception-perl (0.09-2) unstable; urgency=low * New release to debian, fix build-depends by ftp-master's review. -- Dmitry E. Oboukhov Thu, 10 Jan 2013 16:23:09 +0400 libmojolicious-plugin-mailexception-perl (0.09-1) nowtaxi; urgency=low * Some perldoc fixes. -- Dmitry E. Oboukhov Tue, 08 Jan 2013 16:54:39 +0400 libmojolicious-plugin-mailexception-perl (0.08-1) nowtaxi; urgency=low * Add information about vcs/homepage into Makefile.PL. -- Dmitry E. Oboukhov Mon, 07 Jan 2013 02:58:16 +0400 libmojolicious-plugin-mailexception-perl (0.07-1) nowtaxi; urgency=low * Fix 'uninitialized value' warning, thanks to Renée Bäcker for bugreport https://rt.cpan.org/Ticket/Display.html?id=82528. -- Dmitry E. Oboukhov Mon, 07 Jan 2013 02:46:08 +0400 libmojolicious-plugin-mailexception-perl (0.06-1) nowtaxi; urgency=low * The module can really use perl 5.8.8, thanks to Renée Bäcker for bugreport https://rt.cpan.org/Ticket/Display.html?id=82527. -- Dmitry E. Oboukhov Mon, 07 Jan 2013 01:51:50 +0400 libmojolicious-plugin-mailexception-perl (0.05-1) nowtaxi; urgency=low * New release (if Mojo has already prepared exception object the plugin wont update the exception). -- Dmitry E. Oboukhov Fri, 04 Jan 2013 15:46:25 +0400 libmojolicious-plugin-mailexception-perl (0.04-1) nowtaxi; urgency=low * New release (uses Mojo::Exception->new properly). -- Dmitry E. Oboukhov Thu, 03 Jan 2013 01:20:46 +0400 libmojolicious-plugin-mailexception-perl (0.03-2) nowtaxi; urgency=low * New release (lines_after can be absent). -- Dmitry E. Oboukhov Sat, 22 Dec 2012 19:04:28 +0400 libmojolicious-plugin-mailexception-perl (0.02-1) unstable; urgency=low * New release * drop Changes, uses debian/changelog instead, * update documentation * Upload module to debian, closes: 696226 -- Dmitry E. Oboukhov Tue, 18 Dec 2012 15:30:02 +0400 libmojolicious-plugin-mailexception-perl (0.01-1) nowtaxi; urgency=low * Initial Release. -- Dmitry E. Oboukhov Tue, 18 Dec 2012 15:07:49 +0400 Mojolicious-Plugin-MailException-0.24/debian/compat0000644000175000017500000000000213316632153021357 0ustar uneraunera8 Mojolicious-Plugin-MailException-0.24/debian/rules0000755000175000017500000000131513316632153021241 0ustar uneraunera#!/usr/bin/make -f PKG := $(shell dpkg-parsechangelog|grep ^Source|awk '{print $$2}') MOD := $(shell cat Makefile.PL|grep VERSION_FROM \ |sed 's/[[:space:]]\+//g'|sed 's/.*lib/lib/'|sed 's/\.pm.*$$/.pm/') MV := $(shell perl -le \ "`grep VERSION $(MOD)`; print \$$VERSION") DV := $(shell dpkg-parsechangelog |grep ^Version \ |awk '{print $$2}'|sed 's/-[[:digit:]]\+$$//') tarball: clean test "$(MOD) v$(MV)" = "$(MOD) v$(DV)" test -d ../$(PKG)-$(MV) cd .. && \ tar --exclude=debian --exclude=.git -czvf \ $(PKG)_$(MV).orig.tar.gz \ $(PKG)-$(MV) override_dh_clean: dh_clean rm -f Mojolicious-Plugin-MailException-*.tar.gz %: dh $@ override_dh_installchangelogs: dh_installchangelogs -XChanges Mojolicious-Plugin-MailException-0.24/debian/libmojolicious-plugin-mailexception-perl.docs0000644000175000017500000000000713316632153031146 0ustar unerauneraREADME Mojolicious-Plugin-MailException-0.24/debian/source/0000755000175000017500000000000013316653152021463 5ustar unerauneraMojolicious-Plugin-MailException-0.24/debian/source/format0000644000175000017500000000001413316632153022667 0ustar uneraunera3.0 (quilt) Mojolicious-Plugin-MailException-0.24/debian/control0000644000175000017500000000132513316632153021565 0ustar unerauneraSource: libmojolicious-plugin-mailexception-perl Section: perl Priority: optional Maintainer: Dmitry E. Oboukhov Uploaders: Roman V. Nikolaev Build-Depends: debhelper (>= 8) Build-Depends-Indep: libmime-lite-perl, libmime-tools-perl, libmojolicious-perl, perl Standards-Version: 3.9.3 Homepage: http://search.cpan.org/dist/Mojolicious-Plugin-MailException/ Package: libmojolicious-plugin-mailexception-perl Architecture: all Depends: ${misc:Depends}, ${perl:Depends}, libmime-lite-perl, libmime-tools-perl, libmojolicious-perl Description: Mojolicious plugin to send crash information by email The plugin catches all exceptions, packs them into email and sends them to email. Mojolicious-Plugin-MailException-0.24/Makefile.PL0000644000175000017500000000166413316632153020720 0ustar uneraunerause 5.008008; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Mojolicious::Plugin::MailException', VERSION_FROM => 'lib/Mojolicious/Plugin/MailException.pm', PREREQ_PM => { 'Mojolicious' => 0, 'MIME::Words' => 0, 'MIME::Lite' => 0, }, ($] >= 5.005 ? (ABSTRACT_FROM => 'lib/Mojolicious/Plugin/MailException.pm', AUTHOR => 'Dmitry E. Oboukhov ') : ()), LICENSE => 'Perl', META_MERGE => { resources => { homepage => 'https://github.com/dr-co/libmojolicious-plugin-mail_exception', repository => 'https://github.com/dr-co/libmojolicious-plugin-mail_exception', bugtracker => 'https://github.com/dr-co/libmojolicious-plugin-mail_exception/issues', } } ); open my $fh, '>>', 'Makefile' or exit 0; print $fh "\n\nTEST_VERBOSE=1\n\n"; Mojolicious-Plugin-MailException-0.24/README0000644000175000017500000000222313316632153017616 0ustar unerauneraMojolicious-Plugin-MailException ================================ The README is used to introduce the module and provide instructions on how to install the module, any machine dependencies it may have (for example C compilers and installed libraries) and any other information that should be provided before the module is installed. A README file is required for CPAN modules since CPAN extracts the README file from a module distribution so that people browsing the archive can use it get an idea of the modules uses. It is usually a good idea to provide version information here so that people can decide whether fixes for the module are worth downloading. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES The module is plugin for Mojolicious to send crash information to email. COPYRIGHT AND LICENCE Copyright (C) 2012 by Dmitry E. Oboukhov 2012 by Roman V. Nikolaev This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. Mojolicious-Plugin-MailException-0.24/META.yml0000664000175000017500000000157213316653152020221 0ustar uneraunera--- abstract: 'Mojolicious plugin to send crash information by email' author: - 'Dmitry E. Oboukhov ' build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.1002, CPAN::Meta::Converter version 2.150005' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Mojolicious-Plugin-MailException no_index: directory: - t - inc requires: MIME::Lite: '0' MIME::Words: '0' Mojolicious: '0' resources: bugtracker: https://github.com/dr-co/libmojolicious-plugin-mail_exception/issues homepage: https://github.com/dr-co/libmojolicious-plugin-mail_exception repository: https://github.com/dr-co/libmojolicious-plugin-mail_exception version: '0.24' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Mojolicious-Plugin-MailException-0.24/t/0000755000175000017500000000000013316653152017204 5ustar unerauneraMojolicious-Plugin-MailException-0.24/t/020-maildir.t0000644000175000017500000000534513316636462021325 0ustar uneraunera#!/usr/bin/perl use warnings; use strict; use utf8; use open qw(:std :utf8); use lib qw(lib ../lib); use FindBin; use lib "$FindBin::Bin/../lib"; use Test::More tests => 17; use Encode qw(decode encode decode_utf8); my @elist; my @mails; BEGIN { # Подготовка объекта тестирования для работы с utf8 my $builder = Test::More->builder; binmode $builder->output, ":utf8"; binmode $builder->failure_output, ":utf8"; binmode $builder->todo_output, ":utf8"; use_ok 'Test::Mojo'; require_ok 'Mojolicious'; require_ok 'MIME::Lite'; require_ok 'MIME::Words'; use_ok 'File::Temp', 'tempdir'; require_ok 'Mojolicious::Plugin::MailException'; } my $dir = tempdir CLEANUP => 1; my $t = Test::Mojo->new('MpemTest'); # Workaround for newer Mojolicious Versions so the Namespace stays the same $t->app->routes->namespaces(['MpemTest']) if $t->app->can('routes') and $t->app->routes->can('namespaces'); $t->get_ok('/') ->status_is(200) ->content_is('Hello'); $t->get_ok('/crash') ->status_is(500) ->content_like(qr{^Exception: die marker1 outside eval}) ->content_like(qr/Exception Line: die "die marker1 outside eval"; ### die marker1\n$/); my ($mail) = glob "$dir/*"; like $mail, qr{^$dir/\d+\.\d+$}, 'file created'; my $fh; ok open($fh, '<:raw', $mail), 'file opened'; my $data = do { local $/; <$fh> }; like $data => qr{^From:}m, 'From'; like $data => qr{^To:}m, 'To'; package MpemTest::Ctl; use Mojo::Base 'Mojolicious::Controller'; sub hello { $_[0]->render(text => 'Hello'); } sub crash { eval { die "die marker1 inside eval"; }; die "die marker1 outside eval"; ### die marker1 } sub crash_sig { local $SIG{__DIE__} = sub { die $_[0]; }; die "die marker2 sig"; ### die marker2 } sub crash_sub { $_[0]->mail_exception("mail exception marker3", { 'x-test' => 123 }); ### die marker3 } package MpemTest; use utf8; use strict; use warnings; use Mojo::Base 'Mojolicious'; sub startup { my ($self) = @_; $self->secrets(['my secret phrase']); $self->mode('development'); push @{$self->renderer->classes}, 'MpemTest'; $self->plugin('MailException', maildir => $dir, $ENV{FROM} ? ( from => $ENV{FROM} ) : (), $ENV{TO} ? ( to => $ENV{TO} ) : (), subject => 'Случилось страшное (тест)!', headers => {}, ); my $r = $self->routes; $r->get('/')->to('ctl#hello'); $r->get('/crash')->to('ctl#crash'); $r->get('/crash_sig')->to('ctl#crash_sig'); $r->get('/crash_sub')->to('ctl#crash_sub'); } 1; __DATA__ @@ exception.html.ep Exception: <%== $exception %> Exception Line: <%== $exception->line->[1] %> Mojolicious-Plugin-MailException-0.24/t/010-tplugun.t0000644000175000017500000000756213316632153021375 0ustar uneraunera#!/usr/bin/perl use warnings; use strict; use utf8; use open qw(:std :utf8); use lib qw(lib ../lib); use FindBin; use lib "$FindBin::Bin/../lib"; use Test::More tests => 30; use Encode qw(decode encode decode_utf8); my @elist; my @mails; BEGIN { # Подготовка объекта тестирования для работы с utf8 my $builder = Test::More->builder; binmode $builder->output, ":utf8"; binmode $builder->failure_output, ":utf8"; binmode $builder->todo_output, ":utf8"; use_ok 'Test::Mojo'; require_ok 'Mojolicious'; require_ok 'MIME::Lite'; require_ok 'MIME::Words'; require_ok 'Mojolicious::Plugin::MailException'; } my $t = Test::Mojo->new('MpemTest'); # Workaround for newer Mojolicious Versions so the Namespace stays the same $t->app->routes->namespaces(['MpemTest']) if $t->app->can('routes') and $t->app->routes->can('namespaces'); $t->get_ok('/') ->status_is(200) ->content_is('Hello'); $t->get_ok('/crash') ->status_is(500) ->content_like(qr{^Exception: die marker1 outside eval}) ->content_like(qr{Exception Line: die "die marker1 outside eval"; ### die marker1\n$}); is scalar @elist, 1, 'one caugth exception'; my $e = shift @elist; like $e->message, qr{^die marker1 outside eval}, 'text of message'; like $e->line->[1], qr{^ die "die marker1 outside eval"; ### die marker1$}, 'line'; is scalar @mails, 1, 'one prepared mail'; my $m = shift @mails; # note decode_utf8 $t->tx->res->to_string; # note decode_utf8 $m->as_string; note decode_utf8 $m->as_string if $ENV{SHOW}; $m->send if $ENV{SEND}; isa_ok $m => 'MIME::Lite'; $m = $m->as_string; like $m, qr{^Stack}m, 'Stack'; like $m, qr{^Content-Disposition:\s*inline}m, 'Content-Disposition'; @mails = (); $t->get_ok('/crash_sig') ->status_is(500) ->content_like(qr{^Exception: die marker2 sig}) ->content_like(qr{Exception Line: die "die marker2 sig"; ### die marker2\n$}); is scalar @mails, 1, 'one prepared mail'; $m = shift @mails; # note decode_utf8 $m->as_string; @mails = (); $t -> get_ok('/crash_sub') -> status_is(500) -> content_like(qr{^Exception: mail exception marker3}) -> content_like(qr{Exception Line:.*?mail_exception.".*?### die marker3\n$}) ; # couldn get thi to work: # ->content_like(qr!Exception Line: \$_[0]->mail_exception("mail exception marker3", { 'x-test' => 123 }); ### die marker3!); is scalar @mails, 1, 'one prepared mail'; $m = shift @mails; like $m->header_as_string, qr{^X-Test:\s*123$}m, 'Additional header'; package MpemTest::Ctl; use Mojo::Base 'Mojolicious::Controller'; sub hello { $_[0]->render(text => 'Hello'); } sub crash { eval { die "die marker1 inside eval"; }; die "die marker1 outside eval"; ### die marker1 } sub crash_sig { local $SIG{__DIE__} = sub { die $_[0]; }; die "die marker2 sig"; ### die marker2 } sub crash_sub { $_[0]->mail_exception("mail exception marker3", { 'x-test' => 123 }); ### die marker3 } package MpemTest; use utf8; use strict; use warnings; use Mojo::Base 'Mojolicious'; sub startup { my ($self) = @_; $self->secrets(['my secret phrase']); $self->mode('development'); push @{$self->renderer->classes}, 'MpemTest'; $self->plugin('MailException', send => sub { my ($m, $e) = @_; push @elist => $e; push @mails => $m; }, $ENV{FROM} ? ( from => $ENV{FROM} ) : (), $ENV{TO} ? ( to => $ENV{TO} ) : (), subject => 'Случилось страшное (тест)!', headers => {}, ); my $r = $self->routes; $r->get('/')->to('ctl#hello'); $r->get('/crash')->to('ctl#crash'); $r->get('/crash_sig')->to('ctl#crash_sig'); $r->get('/crash_sub')->to('ctl#crash_sub'); } 1; __DATA__ @@ exception.html.ep Exception: <%== $exception %> Exception Line: <%== $exception->line->[1] %> Mojolicious-Plugin-MailException-0.24/META.json0000664000175000017500000000256513316653152020374 0ustar uneraunera{ "abstract" : "Mojolicious plugin to send crash information by email", "author" : [ "Dmitry E. Oboukhov " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.1002, CPAN::Meta::Converter version 2.150005", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Mojolicious-Plugin-MailException", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "MIME::Lite" : "0", "MIME::Words" : "0", "Mojolicious" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/dr-co/libmojolicious-plugin-mail_exception/issues" }, "homepage" : "https://github.com/dr-co/libmojolicious-plugin-mail_exception", "repository" : { "url" : "https://github.com/dr-co/libmojolicious-plugin-mail_exception" } }, "version" : "0.24", "x_serialization_backend" : "JSON::PP version 2.27300_01" } Mojolicious-Plugin-MailException-0.24/MANIFEST0000644000175000017500000000066713316653153020104 0ustar unerauneralib/Mojolicious/Plugin/MailException.pm Makefile.PL MANIFEST README t/010-tplugun.t t/020-maildir.t debian/changelog debian/compat debian/control debian/copyright debian/libmojolicious-plugin-mailexception-perl.docs debian/rules debian/source/format debian/watch Changes META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Mojolicious-Plugin-MailException-0.24/Changes0000644000175000017500000001245513316653031020237 0ustar unerauneralibmojolicious-plugin-mailexception-perl (0.24-1) unstable; urgency=medium * Do not croak if maildir is not accessible. -- Dmitry E. Oboukhov Tue, 03 Jul 2018 13:52:36 +0300 libmojolicious-plugin-mailexception-perl (0.23-1) nowtaxi; urgency=medium * Update version. Prevent hangs up if someone remove maildir. -- Dmitry E. Oboukhov Tue, 03 Jul 2018 12:17:14 +0300 libmojolicious-plugin-mailexception-perl (0.22-1) nowtaxi; urgency=medium * Add 'maildir' configoption. -- Dmitry E. Oboukhov Tue, 03 Jul 2018 12:09:32 +0300 libmojolicious-plugin-mailexception-perl (0.21-1) nowtaxi; urgency=medium * Stacksize limit. -- Dmitry E. Oboukhov Wed, 04 Apr 2018 16:53:52 +0300 libmojolicious-plugin-mailexception-perl (0.20-1) unstable; urgency=medium * Update for latest mojolicious, Debian FTBFS, closes: 825541. -- Dmitry E. Oboukhov Sun, 05 Jun 2016 13:33:41 +0300 libmojolicious-plugin-mailexception-perl (0.19-1) unstable; urgency=medium * Some fixes for Mojo v.5, closes: #765004 thanks to Stephan Jauernick . -- Dmitry E. Oboukhov Fri, 17 Oct 2014 23:44:06 +0400 libmojolicious-plugin-mailexception-perl (0.18-1) unstable; urgency=low * User can add different tags for exceptions. -- Dmitry E. Oboukhov Wed, 06 Nov 2013 11:29:05 +0400 libmojolicious-plugin-mailexception-perl (0.17-1) unstable; urgency=low * New release, closes: #713231 - New Mojo uses render(text => $text) instead reder_text($text). -- Dmitry E. Oboukhov Sat, 17 Aug 2013 12:09:17 +0400 libmojolicious-plugin-mailexception-perl (0.16-1) unstable; urgency=low * Works properly if client's application redefines $SIG{__DIE__}, too. -- Dmitry E. Oboukhov Sun, 24 Mar 2013 00:24:49 +0400 libmojolicious-plugin-mailexception-perl (0.15-1) unstable; urgency=low * use CORE::die instead die (try to localize modperl's segfaults). -- Dmitry E. Oboukhov Wed, 20 Mar 2013 02:30:07 +0400 libmojolicious-plugin-mailexception-perl (0.14-1) unstable; urgency=low * Plugin doesn't catch transitional exceptions. -- Dmitry E. Oboukhov Tue, 19 Mar 2013 17:44:25 +0400 libmojolicious-plugin-mailexception-perl (0.12-1) unstable; urgency=low * $SIG{__DIE__} doesn't modify original exception. -- Dmitry E. Oboukhov Thu, 14 Mar 2013 02:47:37 +0400 libmojolicious-plugin-mailexception-perl (0.11-2) unstable; urgency=low * Add Roman V. Nikolaev to uploaders list. * Upload last fixes into Debian. -- Dmitry E. Oboukhov Sun, 10 Feb 2013 22:36:04 +0400 libmojolicious-plugin-mailexception-perl (0.11-1) nowtaxi; urgency=low * Don`t catch eval exception. -- Roman V. Nikolaev Sat, 09 Feb 2013 15:27:40 +0400 libmojolicious-plugin-mailexception-perl (0.10-1) nowtaxi; urgency=low * Fix exception catching if exception is object. -- Roman V. Nikolaev Sat, 09 Feb 2013 15:16:22 +0400 libmojolicious-plugin-mailexception-perl (0.09-2) unstable; urgency=low * New release to debian, fix build-depends by ftp-master's review. -- Dmitry E. Oboukhov Thu, 10 Jan 2013 16:23:09 +0400 libmojolicious-plugin-mailexception-perl (0.09-1) nowtaxi; urgency=low * Some perldoc fixes. -- Dmitry E. Oboukhov Tue, 08 Jan 2013 16:54:39 +0400 libmojolicious-plugin-mailexception-perl (0.08-1) nowtaxi; urgency=low * Add information about vcs/homepage into Makefile.PL. -- Dmitry E. Oboukhov Mon, 07 Jan 2013 02:58:16 +0400 libmojolicious-plugin-mailexception-perl (0.07-1) nowtaxi; urgency=low * Fix 'uninitialized value' warning, thanks to Renée Bäcker for bugreport https://rt.cpan.org/Ticket/Display.html?id=82528. -- Dmitry E. Oboukhov Mon, 07 Jan 2013 02:46:08 +0400 libmojolicious-plugin-mailexception-perl (0.06-1) nowtaxi; urgency=low * The module can really use perl 5.8.8, thanks to Renée Bäcker for bugreport https://rt.cpan.org/Ticket/Display.html?id=82527. -- Dmitry E. Oboukhov Mon, 07 Jan 2013 01:51:50 +0400 libmojolicious-plugin-mailexception-perl (0.05-1) nowtaxi; urgency=low * New release (if Mojo has already prepared exception object the plugin wont update the exception). -- Dmitry E. Oboukhov Fri, 04 Jan 2013 15:46:25 +0400 libmojolicious-plugin-mailexception-perl (0.04-1) nowtaxi; urgency=low * New release (uses Mojo::Exception->new properly). -- Dmitry E. Oboukhov Thu, 03 Jan 2013 01:20:46 +0400 libmojolicious-plugin-mailexception-perl (0.03-2) nowtaxi; urgency=low * New release (lines_after can be absent). -- Dmitry E. Oboukhov Sat, 22 Dec 2012 19:04:28 +0400 libmojolicious-plugin-mailexception-perl (0.02-1) unstable; urgency=low * New release * drop Changes, uses debian/changelog instead, * update documentation * Upload module to debian, closes: 696226 -- Dmitry E. Oboukhov Tue, 18 Dec 2012 15:30:02 +0400 libmojolicious-plugin-mailexception-perl (0.01-1) nowtaxi; urgency=low * Initial Release. -- Dmitry E. Oboukhov Tue, 18 Dec 2012 15:07:49 +0400