Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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


In reply to mod_perl: how to display the error message within the ErrorDocument by projekt21

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (8)
As of 2024-03-28 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found