Saving/Emailing debug information on "die" in production
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
On 26 July 2012 16:22, Assaf Gordon <gordon@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
Alex C wrote, On 07/27/2012 09:39 AM:
On 26 July 2012 16:22, Assaf Gordon <gordon@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. 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. -gordon
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@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
On 07/27/2012 04:59 PM, Assaf Gordon wrote:
Alex C wrote, On 07/27/2012 09:39 AM:
On 26 July 2012 16:22, Assaf Gordon<gordon@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.
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.
I didn't try that, but before_error_render resp. before_error_init gives you the error object. That might be sufficient to render it yourself and send it by email. Regards Racke -- LinuXia Systems => http://www.linuxia.de/ Expert Interchange Consulting and System Administration ICDEVGROUP => http://www.icdevgroup.org/ Interchange Development Team
participants (4)
-
Alex C -
Assaf Gordon -
Joel Roth -
Stefan Hornburg (Racke)