Hi Viv.
Looks like your code works the way I expected mine to work. After doing some looking I found that my base custom class had an error method in it. Taking that out fixed this problem but caused many other problems. I can't seem to be able to override or hide the error() method (any ideas?) so I will have to re-factor my code so I can have a base class that does not have an error() method.
Thanks for your help.
>>>Hi,
>>>Should work.
>>>Are you saying that the Throw in retParm() fires but that it's not caught in the completewhere func?
>>Yes
>>
>>>IAC, as the code stands, the TRY/CATCH block in retParm() is redundant since you're not handling the exception in any meaningful way.
>>That is the point. I want to handle the error in the completewhere() method. My interpretation of the docs says that throw will throw the error to the calling method's error handler????
>
>It should. But it you only want to handle it in the calling method that should happen automatically without needing to specifically CATCH and THROW.. Where does the execution path in your code vary from this:
SET STEP ON
>=completewhere();
>
>FUNCTION completewhere()
>TRY
> retParm()
>CATCH TO loError
> =MESSAGEBOX("retParm() Caught")
>ENDTRY
>TRY
> retParm2()
>CATCH
> =MESSAGEBOX("retParm2() Caught")
>ENDTRY
>ENDFUNC
>
>FUNCTION retParm()
>TRY
> ERROR 1
>CATCH TO loError
> MESSAGEBOX("Catch in retParm()")
> THROW loError
>ENDTRY
>ENDFUNC
>
>FUNCTION retParm2()
>ERROR 1
>ENDFUNC
>
>>
>>>
>>>>The error does not throw forward. I would like the completewhere() method to catch the error so I can run the getReqiredParms() method. That is not happening.
>>>>>What seems to be a problem?
>>>>>>
>>>>>>I am trying to get a nested try catch to work using throw with little success. I am trying to get the retParm() method to throw an error and have the completewhere() method catch the error. Is this possible?
>>>>>>
>>>>>>Thanks.
>>>>>>
>>>>>>Here is the code
>>>>>>
>>>>>> FUNCTION completewhere()
>>>>>> LOCAL llRet
>>>>>> llRet = .t.
>>>>>> TRY
>>>>>> this.oparm = this.oParmObj.retparm()
>>>>>> CATCH TO loError
>>>>>> * catch the error here and run the method below.
>>>>>> this.getReqiredParms()
>>>>>> FINALLY
>>>>>> this.oParmObj.removeall()
>>>>>> ENDTRY
>>>>>> return llRet
>>>>>> ENDFUNC
>>>>>>
>>>>>> FUNCTION retParm()
>>>>>> LOCAL loRet , loError
>>>>>> loRet = CREATEOBJECT("empty")
>>>>>> TRY
>>>>>> FOR lnx = 1 TO this.count
>>>>>> ADDPROPERTY(loRet,this.aitems[lnx,2],this.aitems[lnx,1])
>>>>>> NEXT
>>>>>> CATCH TO loError
>>>>>> * error occurs and throw the error to completewhere()
>>>>>> THROW loError
>>>>>> FINALLY
>>>>>>
>>>>>> ENDTRY
>>>>>> return loRet
>>>>>> ENDFUNC
>>>>>>
>>>>>>