Mojoli...eption(3pm)

πŸ“¦
version 0.24 Β· 2 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– Mojolicious::Plugin::MailException πŸ’–

okay bestie, gather round, because this one is literally the "your app crashed and nobody told you" fixer, and it lives in the User Contributed Perl Documentation corner of the perl world. it's giving emergency group chat for your exceptions. 🚨✨


πŸŽ€ NAME πŸŽ€

Mojolicious::Plugin::MailException β€” a Mojolicious plugin that catches your app's crashes and emails the receipts straight to you. no cap. πŸ’Œ


🌸 SYNOPSIS 🌸

here's the whole vibe in one go, copy it exactly, don't be cute with it:

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
    });
}

✨ DESCRIPTION ✨

so the tea is: this plugin catches all the exceptions, packs them into an email, and sends them to email. that's it. that's the whole job. main character energy for your error handling. πŸ‘‘

and now, the options, bestie, in order, no skips:

  • from β€” the From-address on the email (default is root@localhost) πŸ“§
  • to β€” the To-address(es) on the email (default is webmaster@localhost)
  • subject β€” the subject line for the crash email
  • headers β€” a hash of headers you want added onto the mail
  • stack β€” how big the stack is in the crash mail. default is 20.
  • maildir β€” this one saves (stores) the messages in the maildir instead of sending them. why would you want that? because if you catch too many crashes, sending them all is probably eating way too much CPU 😭 so with this option you just stash your messages instead of yeeting them out. > heads up bestie: this option gets ignored if the "send" option is defined. periodt.
  • send β€” a subroutine you can use to send the mail yourself. example:
sub startup {
    my ($self) = @_;

    $self->plugin(MailException => {
        send => sub {
            my ($mail, $exception) = @_;

            $mail->send;    # prepared MIME::Lite object
        }
    });
}

inside that function you can send the email by yourself and (or) prepare and send your own mail (sms, etc) message using the $exception object. go look at Mojo::Exception for that. πŸ¦‹


the plugin also hands you an extra method (a helper) called mail_exception:

$cx->mail_exception('my_error', { 'X-Add-Header' => 'value' });

you can use that helper to raise an exception with extra mail headers attached. iconic. πŸ’…


🌈 VCS 🌈

the plugin is placed on github at <https://github.com/dr-co/libmojolicious-plugin-mail_exception> 🫢


 Copyright (C) 2012 by Dmitry E. Oboukhov <unera@debian.org>
 Copyright (C) 2012 by Roman V. Nikolaev <rshadow@rambler.ru>

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. slay. πŸ’œ


and that's the whole page, bestie! this one came from perl v5.40.1, dated 2025-09-24, filed under Mojoli...eption(3pm) in the User Contributed Perl Documentation set. mwah, go forth and get emailed about your crashes. πŸ’–βœ¨

πŸ“¦ where this page comes from