You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jeff Macdonald <je...@inforonics.com> on 2000/06/22 22:29:56 UTC

ErrorDocument, logging and error-notes question

Hi,
I found this interesting tidbit from the Eagle book on page 460:
	... In addition, the message will be saved in the request's notes
table, under a key named error-notes. ...

And on page 454:
	... For example, the logging API saves error messages under a key named
error-notes, which could be used by ErrorDocuments to provide a more
informative message. ...

So this make me think that I could do something like this:

package MyError;

use strict;
use Apache::Constants qw(:common);

sub handler {
	my $r=shift;

	my $error=$r->notes('error-notes');

	$r->content_type('text/html');
	$r->send_http_header();
	$r->print(<<END);
<html>
	<head><title>Error Test</title></head>
	<body>The error stored in error-notes is: $error</body>
</html>
END
	
	return OK;
}

1;

in httpd.conf:

ErrorDocument 500 /error

<Location /error>
        SetHandler Perl-script
        PerlHandler MyError
</Location>

My thinking is that $error would contain the error recorded in the
error_log file.

Instead $error is empty. Any thoughts?

Re: ErrorDocument, logging and error-notes question

Posted by darren chamberlain <da...@boston.com>.
Jeff Macdonald (jeff.macdonald@inforonics.com) said something to this effect:
> Hi,
> I found this interesting tidbit from the Eagle book on page 460:
> 	... In addition, the message will be saved in the request's notes
> table, under a key named error-notes. ...
> 
> And on page 454:
> 	... For example, the logging API saves error messages under a key named
> error-notes, which could be used by ErrorDocuments to provide a more
> informative message. ...

Have you tried setting %n in your LogFormat, to see if that note is visible
to the native logging module? If it is empty there then it would seem that
it is not being set correctly.

the text on p 460 reads to me like this: if you call $r->log yourself, it will
get saved in $r->notes('error-notes') but is not done automatically when you
return SERVER_ERROR. So, you would call do something like:

    my $p = $r->param('p') || do {
        $r->log("Required parameter 'p' missing.");
        return SERVER_ERROR;
    };

And pick up the error-notes value in your SERVER_ERROR handler. 

darren

-- 
Shame is an improper emotion invented by pietists to oppress the human race.

Re: ErrorDocument, logging and error-notes question

Posted by Tom Mornini <tm...@infomania.com>.
On Fri, 23 Jun 2000, Jeff Macdonald wrote:

> Tom Mornini wrote:
> > 
> > On Thu, 22 Jun 2000, Jeff Macdonald wrote:
> > 
> > > My thinking is that $error would contain the error recorded in the
> > > error_log file.
> > >
> > > Instead $error is empty. Any thoughts?
> > 
> > This works in very current versions of mod_perl. What are you running?

> > > Embedded Perl version 5.00503 for Stronghold/2.4.2 Apache/1.3.6
> > > C2NetEU/2412 (Unix) mod_perl/1.21

Too old. I believe the error-notes changes were in 1.24

-- 
-- Tom Mornini
-- InfoMania Printing and Prepress


Re: ErrorDocument, logging and error-notes question

Posted by Jeff Macdonald <je...@inforonics.com>.
Embedded Perl version 5.00503 for Stronghold/2.4.2 Apache/1.3.6
C2NetEU/2412 (Unix) mod_perl/1.21




Tom Mornini wrote:
> 
> On Thu, 22 Jun 2000, Jeff Macdonald wrote:
> 
> > My thinking is that $error would contain the error recorded in the
> > error_log file.
> >
> > Instead $error is empty. Any thoughts?
> 
> This works in very current versions of mod_perl. What are you running?
> 
> --
> -- Tom Mornini
> -- InfoMania Printing and Prepress

Re: ErrorDocument, logging and error-notes question

Posted by Tom Mornini <tm...@infomania.com>.
On Thu, 22 Jun 2000, Jeff Macdonald wrote:

> My thinking is that $error would contain the error recorded in the
> error_log file.
> 
> Instead $error is empty. Any thoughts?

This works in very current versions of mod_perl. What are you running?

-- 
-- Tom Mornini
-- InfoMania Printing and Prepress