Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to handle errors
Message
 
 
To
27/11/2001 13:47:58
Charlie Schreiner
Myers and Stauffer Consulting
Topeka, Kansas, United States
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00586384
Message ID:
00586517
Views:
20
>Hi Michelle,
>Here's what I do in a base container class. I have an oError property that's set to an error object that holds the error number, etc.

Hi Charlie,
I also do something like this except my oError property is oColError because it is a collection of errors. My baseclasses also all have a lErrorOccurred property that can be checked at any time to determine if an error occurred during some process. If it did, I can then query the error collection for every error.

The error collection can return error information in a delimited character string or in XML.

Error event
LPARAMETERS nError, cMethod, nLine
local lcmessage, lcvariable
lcmessage = message()
lcvariable = sys(2018)
With THIS
	.lErrorOccurred = .T.
	if vartype(.oColError) = "O" then
		* there is an error collection so fill it in with this error
		.AddError(nError, cMethod, nLine, lcMessage, lcVariable)
	else
		* if no error collection is specified, make the VFP error handler kick in
		error nError
	endif
Endwith

* Following will simply return and attempt to execute the next line after the 
* one that threw the error.  This can be changed by subclassing this class, 
* issuing a call back to do the error addition in the collection and issuing
* a RETURN TO < some procedure here > in the subclass.
return
AddError method
lparameters tnError, tcMethod, tnLine, tcMessage, tcVariable
local llretval
llretval = .T.
With THIS
	if vartype(.oColError) = "O" then
		* there is an error collection so fill it in with this error
		local loerror
		loerror = .oColError.Add()
		if !isnull(loerror) then
			* got a valid Error object
			With loerror
				.cProgram = tcMethod
				.nError = tnError
				.cError = tcmessage
				.cVariable = tcvariable
				.nLine = tnLine
			Endwith
			loerror = .NULL.
		endif
	else
		* there is no error collection so an error can not be added
		llretval = .F.
	endif
Endwith

return llretval
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform