Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Errorhandling
Message
From
08/01/2015 10:49:44
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
08/01/2015 10:17:38
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8.1
Network:
SAMBA Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01613303
Message ID:
01613305
Views:
65
>>Hi all,
>>
>>I have a problem wit TRY CATCH errorhandling
>>Example
>>
>>lomu = NEWOBJECT('mu')
>>
>>add_p(_SCREEN)
>>
>>lomu.add_x
>>
>>
>>DEFINE CLASS mu AS CONTAINER
>> PROCEDURE ERROR
>>  LPARAMETERS;
>>   tnError,;
>>   tcMethod,;
>>   tnLine,;
>>   tvReturn
>>
>>  ?'Error event'
>> ENDPROC &&mu.error
>>
>> PROCEDURE add_x
>>  add_p(THIS)
>> ENDPROC &&mu.add_x
>>ENDDEFINE &&mu as session
>>
>>
>>PROCEDURE add_p
>> LPARAMETERS lomu
>> TRY
>>   ?lomu.NAME
>>   lomu.ADDOBJECT('mux','xxr')
>>
>>   ?'not catchedd'
>>
>>  CATCH TO loException
>>   ?'catchedd'
>>  FINALLY
>>*
>> ENDTRY
>>ENDPROC &&addp
>>
>>
>>As you can see the call for the object will not be catched by TRY CATCH
>>
>>if there is no ERROR event then it is catched
>>
>>Any idea how catch the error? This is a example for my factory and it fails to catch the problems ...
>>
>>Thanks
>>
>>Lutz
>
>
>help says
>
>For errors that occur in an object's method code, the order of priority for error handlers is summarized as follows:
>
>- Immediate TRY...CATCH, if it exists, in the same method that the error occurs. This applies also to external procedures that a method calls.
>
>- Error event, if it exists, for the object.
>
>- TRY...CATCH at the next level up in the calling chain or in a higher-level method.
>
> - ON ERROR routine, if it exists.
>
>
>ps- past participle of catch is caught

You caught me on the wrong feet.
O.k. This means, even if there is no code in ADDOBJECT, the error occurs in the object.ADDOBJECT so the ERROR event of the method fires.

I hate it. Rewrite every errorhandler to catch it or every ADDOBJECT / NEWOBJECT method of the container classes and some handle to message it down the line.
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform