Yesterday I revisited CGI::Prototype. (Regained my conclusion that I don't know
why it was created.). One thing stood out to me. After the stub starts the
process (by executing $self->activate which is equivalent to C::A's $self->run)
a mainline of method calls to the application's code (control_enter, control,
control_leave, render_enter, render, render_leave, etc.) are wrapped in an
eval. If anything died while executing the application code, it goes to
$self->error to display a common error page.
The idea of die'ing anywhere in my application seems elegant to me. Right now I
have to do my own $template processing anywhere an unexpected/unrecoverable
error occurs (to display a common page).
So, my question is:
C::P's "eval or error" processing would look like this if applied to C::A
(using the POD example, and you'd have to add an error method to your
application):
========
use WebApp;
my $webapp = WebApp->new();
eval {
$webapp->run();
};
$webapp->error($@) if $@; # failed something, go to safe mode
========
Does anyone know a reason *not* to do this? I've always heard "eval" is slow.
Will it slow everything that happens behind the "run" method? Or, is it just a
cost involved with starting eval?
Thanks,
Mark
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]