Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Try... this.error()... and then catch
Message
From
07/05/2004 12:39:03
 
 
To
03/05/2004 13:14:20
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00897769
Message ID:
00901973
Views:
22
Hi Calvin,

you can found a minute to comment these behaviours.

Ok, class event Error() handling priority is a OOP correct implementation
( except for the Error() not escalable limit,
however a solution exist for escalade a error into a class Error event ),
but i have various questions when this is apply to the collection class.

1. You can explain this double error handling.

It have a sense, but i'm not sure that this is by design.
clear
ox=CreateObject("myCollection")

TRY
	ox.Item(null)	&& <== this fire Collection.Error, and then continue, it is ok
	?
	ox(null)	&& <== this fire Collection.Error, 
                        && and after fire Catched code, it is by design ?
	? 'Continue 2'
CATCH
	? "External try/endtry catching",ERROR(),MESSAGE()
ENDTRY


DEFINE CLASS myCollection AS Collection

   	Procedure Error(nError, cMethod, nLine)
		? "Class error catching",ERROR(),MESSAGE()
	ENDPROC

ENDDEFINE
2. I can use this sequence for escalade a error
when it is trapped into a object Error event

( i unknown if this is a VFP behaviour by design,
but if it is not by design, please,
you and VFPT does not consider it a bug, and you leaves it therefore as it is today,
or implement a correct behaviour for Error() handling escalation )
TRY
  THROW
ENDTRY
but on collection.Item method i have found a specific problem
clear
ox=CreateObject("myCollection")

TRY
	ox.Item(1)
	? 'Continue'
CATCH
	? "External try/endtry catching",ERROR(),MESSAGE()
ENDTRY


DEFINE CLASS myCollection AS Collection
	
	PROCEDURE item(zz)
		RETURN DODEFAULT(ZZ)
	ENDPROC
	
   	Procedure Error(nError, cMethod, nLine)
		? "Class error catching",ERROR(),MESSAGE()
		TRY
		   THROW	&& this escalade the error to the first try/endtry level
		ENDTRY
	ENDPROC

ENDDEFINE
but next code fire a not trappable error, like a single THROW line
clear
ox=CreateObject("myCollection")

TRY
	ox.Item(1)
	? 'Continue'
CATCH
	? "External try/endtry catching",ERROR(),MESSAGE()
ENDTRY


DEFINE CLASS myCollection AS Collection
	
*!*	PROCEDURE item(zz)
*!*		RETURN DODEFAULT(ZZ)
*!*	ENDPROC
	
   	Procedure Error(nError, cMethod, nLine)
		? "Class error catching",ERROR(),MESSAGE()
		TRY
		   THROW	&& this fire a not trappable error
		ENDTRY
	ENDPROC

ENDDEFINE
Thanks.

Fabio
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform