Kinyon, Rob wrote:
Error.pm has an intractable memory leak issue regarding closures. I would strongly recommend not using this module unless you can guarantee you do not generate any closures within the try block. -----Original Message-----From: Stephen Howard [mailto:suppressed Sent: Wednesday, March 24, 2004 10:57 AMTo: suppressed Subject: Re: [cgiapp] RE: Changing run modes from another run mode Something else you might consider is using the excellent Error.pm modulefrom CPAN. Then you can do something like this (using rob's subroutine identifiers):sub A { try { sub B() } catch Error with { return sub C() } } sub B { throw Error('error string') if $bad_condition } Error.pm was designed with propagating errors up the call stack in mind, so that they can be handled gracefully at the appropriate level. Kinyon, Rob wrote: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 Btwovalues - 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 haveerrors.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 PMTo: suppressed Subject: Changing run modes from another run modeI 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 anerror, but the error is fixable. I want my utility method to see if ithas an error and then switch to a specific error run mode to fix the error.Theproblem 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--------------------------------------------------------------------- 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
---------------------------------------------------------------------
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.