You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jesse Erlbaum <je...@VM.COM> on 2002/04/12 17:23:17 UTC

Patch to mod_perl 1.26: "error-notes" support

Hello Doug & All --

One of my programmers (Dave Kaufman) brought to my attention a small but
useful feature which is present in mod_cgi, but missing from
Apache::Registry.  When running via mod_cgi, if execution of a CGI
application fails, an error message will be propagated to an environment
variable, "ERROR_NOTES".  This environment variable can be used by a custom
"ErrorDocument" to assist in quality assurance.

This variable is actually propagated, by http_request.c (confirmed in Apache
1.3.20), from an Apache "note" whose key is "error-notes".  A number of
Apache handlers use the "error-notes" attribute to pass along human-readable
exception data.

Following is a patch I wrote (against mod_perl 1.26, Apache::Registry
version 2.01) which causes Apache::Registry to participate in this scheme.
I hope you find it sufficiently useful to include in the next version of
mod_perl.


Warmest regards,

-Jesse-


----START PATCH---->
diff -c -r1.1 Registry.pm
*** modules/i686-linux/Apache/Registry.pm       13 Mar 2002 18:06:34 -0000
1.1
--- modules/i686-linux/Apache/Registry.pm       22 Mar 2002 22:19:10 -0000
***************
*** 129,134 ****
--- 129,135 ----
            if ($@) {
                $r->log_error($@);
                $@{$uri} = $@;
+               $r->notes('error-notes', $@);
                return SERVER_ERROR unless $Debug && $Debug & 2;
                return Apache::Debug::dump($r, SERVER_ERROR);
            }
***************
*** 153,158 ****
--- 154,160 ----
  
        if($errsv) {
            $r->log_error($errsv);
+           $r->notes('error-notes', $errsv);
            return SERVER_ERROR unless $Debug && $Debug & 2;
            return Apache::Debug::dump($r, SERVER_ERROR);
        }
<----END PATCH----



  Jesse Erlbaum, CTO
  Vanguard Media
  http://www.vm.com
  212.242.5317 x115
  jesse@vm.com




Re: Patch to mod_perl 1.26: "error-notes" support

Posted by Doug MacEachern <do...@covalent.net>.
On Tue, 28 May 2002, Geoffrey Young wrote:

> 
> 
> Doug MacEachern wrote:
> 
> > thanks, i've applied a variation of your patch to cvs and will be in 1.27
> > if anybody wants to work up a similar patch for Apache::PerlRun, that'd be 
> > nice too.
> > 
> 
> this seems to work ok as PerlRun and RegistryNG.

looks good, +1.  thanks.


Re: Patch to mod_perl 1.26: "error-notes" support

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Doug MacEachern wrote:

> thanks, i've applied a variation of your patch to cvs and will be in 1.27
> if anybody wants to work up a similar patch for Apache::PerlRun, that'd be 
> nice too.
> 

this seems to work ok as PerlRun and RegistryNG.

--Geoff

--- lib/Apache/PerlRun.pm       25 Mar 2002 01:59:02 -0000      1.38
+++ lib/Apache/PerlRun.pm       28 May 2002 14:38:03 -0000
@@ -28,6 +28,12 @@
      return bless {r=>$r}, $class;
  }

+sub xlog_error {
+    my($r, $msg) = @_;
+    $r->log_error($msg);
+    $r->notes('error-notes', $msg);
+}
+
  sub can_compile {
      my($pr) = @_;
      my $r = $pr->{r};
@@ -52,7 +58,7 @@
         $pr->{'mtime'} = -M _;
         return wantarray ? (OK, $pr->{'mtime'}) : OK;
      }
-    $r->log_error("$filename not found or unable to stat");
+    xlog_error($r, "$filename not found or unable to stat");
      return NOT_FOUND;
  }

@@ -139,7 +145,7 @@
      }

      if($errsv) {
-       $r->log_error($errsv);
+       xlog_error($r, $errsv);
         return SERVER_ERROR;
      }

@@ -211,6 +217,7 @@
      my $pr = shift;
      if ($@ and substr($@,0,4) ne " at ") {
         $pr->{r}->log_error("PerlRun: `$@'");
+       $pr->{r}->notes('error-notes', $@);
         $@{$pr->{r}->uri} = $@;
         $@ = ''; #XXX fix me, if we don't do this Apache::exit() breaks
         return SERVER_ERROR;


Re: Patch to mod_perl 1.26: "error-notes" support

Posted by Doug MacEachern <do...@covalent.net>.
thanks, i've applied a variation of your patch to cvs and will be in 1.27
if anybody wants to work up a similar patch for Apache::PerlRun, that'd be 
nice too.

On Fri, 12 Apr 2002, Jesse Erlbaum wrote:

> Hello Doug & All --
> 
> One of my programmers (Dave Kaufman) brought to my attention a small but
> useful feature which is present in mod_cgi, but missing from
> Apache::Registry.  When running via mod_cgi, if execution of a CGI
> application fails, an error message will be propagated to an environment
> variable, "ERROR_NOTES".  This environment variable can be used by a custom
> "ErrorDocument" to assist in quality assurance.
> 
> This variable is actually propagated, by http_request.c (confirmed in Apache
> 1.3.20), from an Apache "note" whose key is "error-notes".  A number of
> Apache handlers use the "error-notes" attribute to pass along human-readable
> exception data.
> 
> Following is a patch I wrote (against mod_perl 1.26, Apache::Registry
> version 2.01) which causes Apache::Registry to participate in this scheme.
> I hope you find it sufficiently useful to include in the next version of
> mod_perl.
> 
> 
> Warmest regards,
> 
> -Jesse-
> 
> 
> ----START PATCH---->
> diff -c -r1.1 Registry.pm
> *** modules/i686-linux/Apache/Registry.pm       13 Mar 2002 18:06:34 -0000
> 1.1
> --- modules/i686-linux/Apache/Registry.pm       22 Mar 2002 22:19:10 -0000
> ***************
> *** 129,134 ****
> --- 129,135 ----
>             if ($@) {
>                 $r->log_error($@);
>                 $@{$uri} = $@;
> +               $r->notes('error-notes', $@);
>                 return SERVER_ERROR unless $Debug && $Debug & 2;
>                 return Apache::Debug::dump($r, SERVER_ERROR);
>             }
> ***************
> *** 153,158 ****
> --- 154,160 ----
>   
>         if($errsv) {
>             $r->log_error($errsv);
> +           $r->notes('error-notes', $errsv);
>             return SERVER_ERROR unless $Debug && $Debug & 2;
>             return Apache::Debug::dump($r, SERVER_ERROR);
>         }
> <----END PATCH----
> 
> 
> 
>   Jesse Erlbaum, CTO
>   Vanguard Media
>   http://www.vm.com
>   212.242.5317 x115
>   jesse@vm.com
> 
> 
> 
>