Mailing List Archive

custom error handling in CGI mode
I looked in the docs and found a reference to a runtime option that allowed
mod_perl to redirect to a custom error page, but didn't notice any mention
of how to do that in the CGI version...

How is the best way to implement an overall error page that override's
Embperl's and shows up for even the most basic errors??

Thanks!

Jon Brisbin
Re: custom error handling in CGI mode [ In reply to ]
> I looked in the docs and found a reference to a runtime option that
allowed
> mod_perl to redirect to a custom error page, but didn't notice any mention
> of how to do that in the CGI version...
>
> How is the best way to implement an overall error page that override's
> Embperl's and shows up for even the most basic errors??
>

You can let Embperl return the error value to embpcgi.pl (optReturnError).
Then you can call your custom error page at the end of embpcgi.pl. I didn't
tried it, but it should work.

Gerald

-------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 925151
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------
Re: custom error handling in CGI mode [ In reply to ]
> You can let Embperl return the error value to embpcgi.pl (optReturnError).
> Then you can call your custom error page at the end of embpcgi.pl. I
didn't
> tried it, but it should work.

by doing an "Execute or die &errorhandler" ??? or how should i trap that
error??

Thanks!

Jon Brisbin
Re: custom error handling in CGI mode [ In reply to ]
> > You can let Embperl return the error value to embpcgi.pl
(optReturnError).
> > Then you can call your custom error page at the end of embpcgi.pl. I
> didn't
> > tried it, but it should work.
>
> by doing an "Execute or die &errorhandler" ??? or how should i trap that
> error??
>
Take a look at embpcgi.pl. If you set optReturnError in EMBPERL_OPTIONS then
the return value in $rc will contain zero for succes and an error code for
all other cases. embpcgi.pl already outputs a small error document and you
may replace it by your own. Unfortunately you don't have access to the Perl
errors displayed by EMbperl. If you need them you must replace the call to
runcgi by a call to Execute and pass the correct path as inputfile. Execute
is able to return an array with all error messages.

Gerald
Re: custom error handling in CGI mode [ In reply to ]
> Take a look at embpcgi.pl. If you set optReturnError in EMBPERL_OPTIONS
then
> the return value in $rc will contain zero for succes and an error code for
> all other cases. embpcgi.pl already outputs a small error document and you
> may replace it by your own. Unfortunately you don't have access to the
Perl
> errors displayed by EMbperl. If you need them you must replace the call to
> runcgi by a call to Execute and pass the correct path as inputfile.
Execute
> is able to return an array with all error messages.


So the later option would be something like:

my @errors = HTML::Embperl::Execute($ENV{PATH_TRANSLATED});
...handle errors...

??

I couldn't find anywhere in the docs where the return value of Execute was
used...it's all just Execute($blah, $etc)....

What's the syntax of getting error messages that occur from Execute??

Jon Brisbin
Re: custom error handling in CGI mode [ In reply to ]
>
>
> So the later option would be something like:
>
> my @errors = HTML::Embperl::Execute($ENV{PATH_TRANSLATED});
> ...handle errors...
>

No, something like:

my $rc = HTML::Embperl::Execute({inputfile => $ENV{PATH_TRANSLATED},
options =>
HTML::Embperl::optReturnError,
errors => \@errors});

>
> I couldn't find anywhere in the docs where the return value of Execute was
> used...it's all just Execute($blah, $etc)....
>
> What's the syntax of getting error messages that occur from Execute??
>

http://perl.apache.org/embperl/Embperl.pod.2.html#By_calling_HTML_Embperl_Ex
ecut


Gerald
Re: custom error handling in CGI mode [ In reply to ]
will this still send an email of the error, as it does now??

jb

----- Original Message -----
From: Gerald Richter <richter@ecos.de>
To: Jon Brisbin <brisbin@ipa.net>; Embeded PERL ML <embperl@perl.apache.org>
Sent: Tuesday, August 08, 2000 8:32 AM
Subject: Re: custom error handling in CGI mode


> >
> >
> > So the later option would be something like:
> >
> > my @errors = HTML::Embperl::Execute($ENV{PATH_TRANSLATED});
> > ...handle errors...
> >
>
> No, something like:
>
> my $rc = HTML::Embperl::Execute({inputfile => $ENV{PATH_TRANSLATED},
> options =>
> HTML::Embperl::optReturnError,
> errors =>
\@errors});
>
> >
> > I couldn't find anywhere in the docs where the return value of Execute
was
> > used...it's all just Execute($blah, $etc)....
> >
> > What's the syntax of getting error messages that occur from Execute??
> >
>
>
http://perl.apache.org/embperl/Embperl.pod.2.html#By_calling_HTML_Embperl_Ex
> ecut
>
>
> Gerald
>
>
>
Re: custom error handling in CGI mode [ In reply to ]
> No, something like:
>
> my $rc = HTML::Embperl::Execute({inputfile => $ENV{PATH_TRANSLATED},
> options =>
> HTML::Embperl::optReturnError,
> errors =>
\@errors});
>


Now I've tried this:

use HTML::Embperl;

$out = "";
@errors = [];
my $rc = HTML::Embperl::Execute({inputfile => $ENV{PATH_TRANSLATED},
options => HTML::Embperl::optReturnError,
errors => \@errors,
output => \$out});

if($rc ne 0) {
HTML::Embperl::Execute({inputfile =>
"/usr/www/jbrisbin/finder/htdocs/error.ehtml",
param => \@errors,
output => \$out});
}

print $out;


which I don't like, because nothing gets sent to the browser until the page
is completely done...i'm also wondering if i'll ever get a situation where
it'll print two headers, for example...??

it does still send the email, though...that's good! :-)

Any other suggestions on making the output show up faster while the search
is working??

Jon Brisbin
Re: custom error handling in CGI mode [ In reply to ]
----- Original Message -----
From: "Jon Brisbin" <brisbin@ipa.net>
To: "Embeded PERL ML" <embperl@perl.apache.org>
Sent: Tuesday, August 08, 2000 5:50 PM
Subject: Re: custom error handling in CGI mode


> > No, something like:
> >
> > my $rc = HTML::Embperl::Execute({inputfile => $ENV{PATH_TRANSLATED},
> > options =>
> > HTML::Embperl::optReturnError,
> > errors =>
> \@errors});
> >
>[..]
> but i put in an error in the page and it gives me a 500 error because it
> prints the error lines out before the html of my error document:
>
> bash-2.02$ ./epl
> (offline mode: enter name=value pairs on standard input)
> [21024]ERR: 46: Line 71: Unclosed command [$ if $] at end of file
>

If you don't send the http headers on your own, you have to include the
optSendHttpHeader options (runcgi normaly sets this option for you)

>Will I have to just put in an ErrorDocument 500 in my httpd.conf file??

You can use an ErrorDocument if it fit's your need, but when running in cgi
mode you don't have the error messages available there.

>
>
> Now I've tried this:
>
> use HTML::Embperl;
>
> $out = "";
> @errors = [];
> my $rc = HTML::Embperl::Execute({inputfile => $ENV{PATH_TRANSLATED},
> options => HTML::Embperl::optReturnError,
> errors => \@errors,
> output => \$out});
>
> if($rc ne 0) {
> HTML::Embperl::Execute({inputfile =>
> "/usr/www/jbrisbin/finder/htdocs/error.ehtml",
> param => \@errors,
> output => \$out});
> }
>
> print $out;
>
>
> which I don't like, because nothing gets sent to the browser until the
page
> is completely done...i'm also wondering if i'll ever get a situation where
> it'll print two headers, for example...??
>
> it does still send the email, though...that's good! :-)
>

yes

> Any other suggestions on making the output show up faster while the search
> is working??
>

You can set optEarlyHttpHeader, that will send the output imediately
(otherwise Embperl will buffer your output anyway), but in this case you
don't have the chance to send an error page when an error occurs inside the
page, because the headers and the start of the page are already send.

Gerald

-------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 925151
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------