perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luiz Fernando B. Ribeiro" <>
Subject Re: Viewing Previous Request's Post Data
Date Mon, 22 Dec 2003 13:35:31 GMT
Bruce Kessler wrote:
> If I were trying to implement a page for an ErrorDocument directive for a
> 500 error, and I wanted to get the post data from the users request that
> caused the error, how could I get this information back from Apache or
> Embperl?  I am under the impression that using $req_rec->content() will not
> work, nor will $req_rec->prev()->content(), am I right?  It seems that the
> data is consumed already by the time I get the request object and %fdat is
> empty.

This what i do:

1. in httpd.conf
# For optReturnError (see perldoc HTML::Embperl)
ErrorDocument 500 /errors/500.ego

2. If you are using EmbperlObject put this in your template file, 
replacing the usual Execute('*'):
my @errors;
Execute({inputfile => '*', errors => \@errors});	
if (@errors) {
	Execute('Erro_notificar.epr', \@errors);

3. In the file "Erro_notificar.epr":
$req = shift;
$errors = shift @param;

# Do something with the errors, dump, mail...

4. When an error occurs your visitors will be redirected to the 
ErrorDocument file but not all errors will be trapped by the template 
file so in your "/errors/500.epo" you should also capture other errors 
with "pnotes". In /errors/500.epo:

<html> ... Sorry for the error ... </html>

# This is needed to catch other errors not trapped by the template file.
if ($req_rec && ($prev = $req_rec->prev)) {
	$errors = $prev->pnotes('EMBPERL_ERRORS');
	if ($errors && @$errors) {
		unshift @$errors, 'Capturado via pnotes!';
		Execute('Erro_notificar.epr', $erros);

With this technique you can dump %ENV, %fdat and %udat in a debug mail.

I hope this is clear. I use EmbperlObject so my solution fits best with it.

Luiz Fernando B. Ribeiro
Engenho Soluções para a Internet

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message