http://qs321.pair.com?node_id=201706

projekt21 has asked for the wisdom of the Perl Monks concerning the following question:

I want to handle ErrorDocuments with a mod_perl module Apache::MyError in a way that the actual error message (server error 500, as written to the logs) is displayed within the result HTML page.

I know that this is evil, just treat it as an academic approach. (What I want to do in real life is mail the message to the webmaster and display a backtrace id to the user referring to that error)

What I have so far is my httpd.conf,

ErrorDocument 500 /errors/500 <Location /errors> SetHandler perl-script PerlHandler Apache::MyError Options +ExecCGI PerlSendHeader On </Location>

a script that won't compile under /usr/local/apache/cgi-bin/die.pl and the following:

package Apache::Error; use strict; use Apache::Constants qw(:common); sub handler { my $r = Apache->request; my $p = $r->prev; $r->status(OK); $r->content_type("text/html"); $r->send_http_header; $r->print("<pre>\n"); $r->print($r->path_info, "\n"); $r->print($p->notes("error-notes"), "\n"); $r->print("</pre>\n"); return OK; } 1;

The log says:

syntax error at /usr/local/apache/cgi-bin/die.pl line 6, near "if {" Missing right curly or square bracket at /usr/local/apache/cgi-bin/die +.pl line 8, at end of line Execution of /usr/local/apache/cgi-bin/die.pl aborted due to compilati +on errors. [Mon Sep 30 13:42:51 2002] [error] [client xxx.xxx.xxx.xxx] Premature +end of script headers: /usr/local/apache/cgi-bin/die.pl

$p->notes("error-notes") contains "premature end of ..." but not the "syntax error ..." which is the one I want to have.

Can someone guide me to a solution (I know one from mod_ruby using the method error_message)? Am I missing something?

alex pleiner <alex@zeitform.de>
zeitform Internet Dienste