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