I tried the below, but I can't seem to get the ARGS right.  I want to get
the args that were involved in the error.  It comes up with nothing.

On Thu, Jan 6, 2011 at 3:22 PM, Sherrard Burton <sbur...@allafrica.com>wrote:

> the way we did this is to:
>
> use a custom 500 error document for apache
> ErrorDocument 500 /public/error/500.html
>
> then in that file, along with the "pretty" message, we have a call to
> $m->comp( '/private/functions/send_error_email' );
>
> you can also trigger it manually to get some decent
> debugging/environmental info for stuff you're working on.
>
> form_mailer just uses Net::SMTP, or similar to send the message
>
> send_error_email:
> <%args>
>   $_type  =>  'error'
>   $_to    =>  'mason-err...@example.com'
> </%args>
> <%flags>
>   inherit => '/autohandler'
> </%flags>
> <%init>
>   %ARGS = ( %{$m->caller_args(-1)}, %ARGS );
>   my $error_text = "Page is '" . $r->uri() . "'\n\n";
>
>   # try to handle an error, if the object exists
>   if ( my $error = $r->pnotes( 'mason_error' ) ) {
>      $error_text .= UNIVERSAL::can( $error, 'as_text' ) ?
> $error->as_text : $error;
>      $error_text .= "\n\n\n";
>   } else {
>     $r->warn( "error mailing component called with no pnotes from
> '".$m->callers(1)->path()."'" );
>   }
>
>   $error_text .= "Request Method: '".$r->method()."'\n";
>   $error_text .= "The Request: '".$r->the_request()."'\n";
>   $error_text .= "URI: '".$r->uri()."'\n";
>   $error_text .= "\n\n\n";
>
>   $error_text .= "Headers\n";
>   foreach my $key ( sort keys %{$r->headers_in()} ) {
>     $error_text .= "$key: " . $r->header_in( $key ) . "\n";
>   }
>   $error_text .= "\n\n\n";
>
>   $error_text .= $m->scomp( '/scripts/dump_data_structure',
> include_html=> 0, '%ARGS' => \%ARGS );
>   $error_text .= "\n\n\n";
>
>   my %hash = (
>     from=> 'mason-err...@example.com',
>     header_from=> 'Error Handler<mason-err...@example.com>',
>     to=> $_to,
>     subject=> "Mason ".ucfirst( $_type )." on $hostname ".$r->uri(),
>     body=> $error_text,
>   );
>   $m->comp( '/scripts/form_mailer', %hash );
> </%init>
> <%once>
>   my $hostname = Sys::Hostname::hostname();
> </%once>
>
>
>
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to