Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to handle errors
Message
From
27/11/2001 14:38:21
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00586384
Message ID:
00586541
Views:
32
You didn't show up in the CC list, so I'm replying to say thanks to you, too. You guys gave me great ideas.

Thanks,

Michelle

>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform