[Dancer-users] Saving/Emailing debug information on "die" in production

Alex C calyx238 at gmail.com
Fri Jul 27 15:39:20 CEST 2012


On 26 July 2012 16:22, Assaf Gordon <gordon at cshl.edu> wrote:
> Hello dancers,
>
> When a dancer app die()'s in development mode, a detailed runtime error page is generated (with stack trace, config values, session values, environment values, etc.).
>
> In production mode, obviously such information should not be shown to the user - but is there a way to save the information to a file, or better yet - email it to someone ?
>
> Is that a Dancer module, or Plack middle-ware, or something else ?
>
> Thanks,
>  -gordon

You can create a Dancer::Error instance and send it wherever you want:

get '/' => sub {

    eval { die };

    if ($@) {

        my $error = Dancer::Error->new(
            code    => 500,
            message => "Died..."
        );

        send_email( $error->render );

        return send_error;
    }
};

--
Alex


More information about the Dancer-users mailing list