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

Joel Roth joelz at pobox.com
Fri Jul 27 17:28:57 CEST 2012


On Fri, Jul 27, 2012 at 10:59:26AM -0400, Assaf Gordon wrote:
> Alex C wrote, On 07/27/2012 09:39 AM:
> > On 26 July 2012 16:22, Assaf Gordon <gordon at cshl.edu> wrote:
> >>
> >> but is there a way to save the information to a file, or better yet - email it to someone ?
> >>
> > 
> > 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;
> >     }
> > };
> 
> I was hoping for something automatic that will work on any "die" without changing my code between development and production modes.

Not sure it will work, but did you try something like this?

$SIG{__DIE__} = sub { handle_errors() } 
 
> using "after_error_render" hook (as suggested to me in a private email) doesn't work either, because when "show_errors" is disabled, the "$response" object points to the generic HTML error page, not to the nice stack-trace rendered HTML page.

-- 
Joel Roth


More information about the Dancer-users mailing list