On Wed, 1 Nov 2000, Paul J. Lucas wrote:

>       If I'm a few levels deep into function calls, I'd liek to be
>       able to do something like "return SERVER_ERROR" and have the
>       entire call stack unwind and the current request stopped.
> 
>       Is there any way to do that?

Definitely use exceptions. I prefer Error.pm for this (sorry, Dave!),
which allows your handler to simply be:

sub handler {
        return try {
                ...
        } catch Exception::RetCode with {
                my $E = shift;
                return $E->{code};
        } <other exceptions>
        ;
}

And then anywhere within your code you can go:

        throw Exception::RetCode ( code => SERVER_ERROR );

Of course there's a bit of setup to do beyond that, which I intend to
rewrite the section of the guide to detail real soon now (tm).

-- 
<Matt/>

    /||    ** Director and CTO **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // **     Personal Web Site: http://sergeant.org/     **
     \\//
     //\\
    //  \\

Reply via email to