[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cgiapp] RE: Changing run modes from another run mode


Basically, it sounds like your problem boils down to this:
1) You are in runmode A.
2) You call function B.
3) Within function B, you determine you have error condition C.
4) You now need to switch from runmode A to runmode C.

The issue you're running into is the function stack. You have called
function B from within function A. You want to change the stack frame
for function A into the stack frame for function C. Not so simple.

There are a few ways to go about this, some more complicated than
others. The easiest one, in my opinion, is to return from function B two
values - one that indicates an error has occurred and the other
indicating what runmode to call now. Something like:

    my ($error, $runmode) = functionB(@parameters);
    return $self->$runmode if $error;

This method requires runmode A to know that functionB might have errors.
It doesn't require runmode A to know that -this- error goes to -that-
runmode. 

The other solutions tend to be a little more ... complex. I'd try that
one first.

Rob

-----Original Message-----
From: suppressed [mailto:suppressed 
Sent: Tuesday, March 23, 2004 6:48 PM
To: suppressed
Subject: Changing run modes from another run mode

I have what looks like a fairly simple problem. I have a run mode and 
this run mode calls a utility method. The utility method might throw an 
error, but the error is fixable. I want my utility method to see if it
has an 
error and then switch to a specific error run mode to fix the error. The

problem is, of course, I can't switch run modes from my utility method, 
the only place I can switch is from the cgiapp_prerun method. Whats 
the best way to hack around this problem?

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.