Jacek,

While CGI::Carp admittedly doesn't catch everything, it does catch quite a 
few problems.

The problem lies in the fact that Apache::Registry loads the script in 
memory and attempts to compile it using eval.

When you compile a perl block with eval and there is a syntax error in that 
Perl block, it gets treated as a warning not a fatal error. However, 
CGI::Carp will happily catch problems with loading badly written libraries 
in subsequent require and use statements I believe. And it will definitely 
catch quite a few runtime errors such as division by zero or direct 
die/croak/confess statements.

I don't think this is a huge problem because if you are having trouble 
writing Perl code that doesn't compile in the first place, then you always 
have the option to run it from the command line to get the exact error 
message. Compile time errors are much easier to solve than runtime errors 
because they will stop the script from running 100% of the time whereas 
runtime errors usually involve a series of events that is better done in 
the browser (where CGI::Carp can help debugging tremendously).

Later,
    Gunther

PS Another good framework is Matt Sergeant's exception handling framework. 
Of course, his framework won't solve the above problem either. But it does 
solve some other subtle eval problems if you have them in your own scripts 
and modules. There was a long thread about this months ago.

At 08:12 PM 11/25/00 +0100, Jacek Ostrowski wrote:
>darren chamberlain wrote:
> >
> > Jacek Ostrowski ([EMAIL PROTECTED]) said something to this 
> effect:
> > > hi,
> > >
> > > I have a litle suggestion to Apache::Registry -
> > > I tried to change it to allow script writers
> > > to see compile errors in a browser.
> > >
>cut
> >
> > Why not just use CGI::Carp? The fatalsToBrowser function will do exactly
> > what you want Registry to do.
> >
> > (darren)
>
>I tried to use CGI::Carp before, but with no effect.
>Try to run the script below, you will see no syntax error in the
>browser. (?)
>
>-----
>use CGI
>qw/:all/;
>use CGI::Carp
>qw/fatalsToBrowser/;
>
>print
>start_html('Test');
>print
>'test<BR>' 
>
>print end_html;
>-----
>
>yacek
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]

__________________________________________________
Gunther Birznieks ([EMAIL PROTECTED])
eXtropia - The Web Technology Company
http://www.extropia.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to