even better: Apache->exit(SERVER_ERROR);. or die SERVER_ERROR;. this is
documented in the eagle book:
ch9 - The Apache::Constants Class
"...
While the HTTP constants are generally used as return codes from
handler subroutines, it is also possible to use the builtin die()
function to jump out of a handler with a status code that will be
propagated back to Apache. Example:
unless (-r _) {
die FORBIDDEN;
}
"
sterling
On Wed, 1 Nov 2000, Paul J. Lucas wrote:
> On Wed, 1 Nov 2000, Paul J. Lucas wrote:
>
> > Ideally, I want to be able to do:
> >
> > sub foo {
> > if ( $serious_problem )
> > stop_now_dammit( SERVER_ERROR );
> > }
> >
> > anywhere in the code like:
> >
> > sub bar {
> > foo();
> > }
> >
> > and I do *NOT* have to "catch" anything after the point of
> > call, i.e., every call of foo() is similar to an "assertion" in
> > C, i.e., if you get to the line of code after it, it worked; if
> > it didn't work, you never get to the line after it.
>
> I figured out that I can do this by having stop_now_dammit()
> use $r->notes() to set a note of the status code, call
> Apache->exit(), and have the downstream handler check the note.
> If it's anything but OK, simply return that value and the
> normal Apache error handline mechanism kicks in. :)
>
> - Paul
>