John Deighan wrote:
> I need to be able to jump to the end of the enclosing eval block, just like
> a die() does, but without setting [EMAIL PROTECTED] Is there a way to do
> that? (I've
> checked the Perl docs, but couldn't find it). I could possibly die() with a
> specific string, then use "if ($@ && ($@ ne <string>))" as the error trap,
> but that's aesthetically unpleasing.
There are lots of possibilites, why not just set a global vrbl (or at
least one that has scope) indicating the type of error to handle at
the end of the eval block:
my $user_err = 0;
eval {
...
$user_err = 1;
die ...
};
if ($@) {
if ($user_err) {
... # user error
} else {
... # real error
}
}
> If you're interested in why, here's the explanation. Our web site is
> implemented via a series of "opcodes". The opcode is passed in the URL.
> There is a goto in our main script that dispatches to a particular opcode,
> and the code implementing the opcodes is surrounded by an eval block. When
> the output is generated, it's generated via a call to a library that
> outputs a page - usually using a template file. There is, however, also a
> function called errorPage() to which you pass a string. Now, when
> errorPage() is called, there has to be no further HTTP output, so I'd
> prefer, at the end of the errorPage() routine, to pass directly to the end
> of the eval block in the main code. die() does just that, but after the
> eval block, there's a "if ($@)" that handles any real errors, like database
> connection errors, direct calls to die(), etc., and I don't want calls to
> errorPage() to be treated like true errors (they're "user errors", which
> just means that we want to display a page to the user informing them of
> their error and how to correct it, and errorPage() does just that. Real
> errors result in us receiving an e-mail with the error message, and the
> error being logged to a database table).
--
,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs