You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Ben Kim <bk...@coe.tamu.edu> on 2004/04/14 00:28:34 UTC

error trapping and notice

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

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

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

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

Regards,
Ben Kim


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


Re[2]: error trapping and notice

Posted by "Luiz Fernando B. Ribeiro" <lu...@engenhosolucoes.com.br>.
Ben,

Thursday, April 15, 2004, 10:56:47 AM, você escreveu:


BK> We are on 1.3 and are not using Embperl::Object yet. I hope I can use the
BK> above regardlessly. I know I can use Execute, but I'm not familiar about
BK> the extensions epo and epr. What is the pod that explains them?

In fact you can use any extension you want, even .html or .asp...
I use the following extensions:
.epo: EmbperlObject pages
.epl: Plain Embperl pages
.epr: Resource files executed inside other pages, shared pieces of
code.

-- 
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


Re: error trapping and notice

Posted by Angus Lees <gu...@inodes.org>.
At Thu, 15 Apr 2004 08:56:47 -0500 (CDT), Ben Kim wrote:
> 1. error trapping
> > Execute({inputfile => 'file.epl', 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.
> 
> 2. errorpage and notice
> > First configure your own error page
> > ErrorDocument 500 /errors/500.epo
> >   [-
> >     if ($req_rec && ($prev = $req_rec->prev)) {
> >       $errors = $prev->pnotes('EMBPERL_ERRORS');
> >       if ($errors && @$errors) {
> >         Execute('notify_error.epr', $errors);
> >       }
> >     }
> >   -]
> > Second disable the default error page from Embperl
> > PerlSetEnv EMBPERL_OPTIONS 262144
> 
> 3. send out a mail on every error.  (perldoc Embperl::Config)
> > Embperl_Mail_Errors_To
> > config directive 
> 
> Thanks to Luiz and Gerald for the advice. 
> 
> We are on 1.3 and are not using Embperl::Object yet. I hope I can use the
> above regardlessly. I know I can use Execute, but I'm not familiar about
> the extensions epo and epr. What is the pod that explains them?

You can use (1) without using Embperl::Object, but you need to run all
your suspect code via that construct - which is awkward without
Embperl::Object's "base" idea.

(2) should work fine, see "optReturnError" in the HTML::Embperl
manpage.

For Embperl 1.3, (3) will need to be (see HTML::Embperl manpage)
 PerlSetEnv EMBPERL_MAIL_ERRORS_TO ...

The epo and epr extensions are just Luiz's file naming conventions -
they don't mean anything special.

-- 
 - Gus


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


Re: error trapping and notice

Posted by Ben Kim <bk...@coe.tamu.edu>.
I have the following responses. 

1. error trapping
> Execute({inputfile => 'file.epl', 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.

2. errorpage and notice
> First configure your own error page
> ErrorDocument 500 /errors/500.epo
>   [-
>     if ($req_rec && ($prev = $req_rec->prev)) {
>       $errors = $prev->pnotes('EMBPERL_ERRORS');
>       if ($errors && @$errors) {
>         Execute('notify_error.epr', $errors);
>       }
>     }
>   -]
> Second disable the default error page from Embperl
> PerlSetEnv EMBPERL_OPTIONS 262144

3. send out a mail on every error.  (perldoc Embperl::Config)
> Embperl_Mail_Errors_To
> config directive 

Thanks to Luiz and Gerald for the advice. 

We are on 1.3 and are not using Embperl::Object yet. I hope I can use the
above regardlessly. I know I can use Execute, but I'm not familiar about
the extensions epo and epr. What is the pod that explains them?

Thanks,

Ben Kim


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


Re: error trapping and notice

Posted by Gerald Richter <ri...@ecos.de>.
Ben Kim wrote:
> We have quite a few pages using embperl, and sometimes fixing one at
> the site module (pm) level breaks others, which we won't know until a
> certain combination of things happen together.
>
> We'd like to be notified by email when any embperl related error
> happens.
>
> What is the best practice? I hope to handle it within embperl, if
> possible, without running a separate script.
>
> Also, what is the best way to implement an "errorpage" which will be
> the default destination for users if any error occurs?
>

I addition to the two ways to display a custom error page that already wrote
Luiz, you can use the

Embperl_Mail_Errors_To

config directive to send out a mail on every error. See perldoc Config.pod
for more details.

Gerald

---------------------------------------------------------------------------
Gerald Richter            ecos electronic communication services gmbh
IT-Securitylösungen * Webapplikationen mit Apache/Perl/mod_perl/Embperl

Post:       Tulpenstrasse 5          D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de          Voice:   +49 6133 939-122
WWW:        http://www.ecos.de/      Fax:     +49 6133 939-333
---------------------------------------------------------------------------
Besuchen Sie uns auf der CeBIT (18. - 24. März 2004)
Halle 6 Stand B38-452

ECOS BB-5000 Firewall- und IT-Security Appliance: www.bb-5000.info
---------------------------------------------------------------------------


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


Re: error trapping and notice

Posted by "Luiz Fernando B. Ribeiro" <lu...@engenhosolucoes.com.br>.
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