perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luiz Fernando B. Ribeiro" <l...@engenhosolucoes.com.br>
Subject Re: error trapping and notice
Date Wed, 14 Apr 2004 11:41:27 GMT
Ben,

Tuesday, April 13, 2004, 7:28:34 PM, você escreveu:


BK> We have quite a few pages using embperl, and sometimes fixing one at the
BK> site module (pm) level breaks others, which we won't know until a certain
BK> combination of things happen together.

BK> We'd like to be notified by email when any embperl related error happens.

BK> What is the best practice? I hope to handle it within embperl, if
BK> possible, without running a separate script.

BK> Also, what is the best way to implement an "errorpage" which will be the
BK> default destination for users if any error occurs?

Use the following syntax in your Executes:
Execute({inputfile => 'file.epl', errors => \@errors});

Its easier to capture errors under EmbperlObject since you just need
to update your template files:
        [-
        my @errors;
        Execute({inputfile => '*', errors => \@errors});
        if (@errors) {
                Execute('notify_error.epr', \@errors);
        }
        -]


In the "notify_error.epr" page you can send a message with all debugging
data you need like fdat, udat, ENV and etc.

But to not show the default Embperl error page you have to set 2
options in httpd.conf:

First configure your own error page
ErrorDocument 500 /errors/500.epo

Second disable the default error page from Embperl
PerlSetEnv EMBPERL_OPTIONS 262144

With this setup you will also trap ANY error that happens in your
pages, even that not caused inside those trapped Executes. To obtain
the error messages in these cases put the following lines in your
error page (500.epo):

[-
if ($req_rec && ($prev = $req_rec->prev)) {
        $errors = $prev->pnotes('EMBPERL_ERRORS');
        if ($errors && @$errors) {
                Execute('notify_error.epr', $errors);
        }
}
-]

This setup works for me under Embperl 1.3, I don't know how different
it is under Embperl 2.x

Hope this helps,

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


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message