Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
TRY CATCH ENDTRY and COM Server
Message
From
22/07/2003 06:10:55
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
TRY CATCH ENDTRY and COM Server
Miscellaneous
Thread ID:
00812266
Message ID:
00812266
Views:
63
Hello everybody

I have problems catching errors in a COM ole public server object instantiated in an ASP page. The COM server has a method called “KDPAction”, its have the functionality of execute specific functions in a procedure file determined for the received parameters, the code for the KDPAction method is as follow.
LPARAMETERS cAction as string, cXML as String, cFileIni as String

LOCAL I as Integer, cScript as String, cProcedure as String, cFunction as String,;
	cMessage as String

TRY
	This.KDPScripts = ADDBS(This.ReadFileIni(cFileIni,"DIRECTORY","SCRIPTS"))
	This.KDPSysDB = ADDBS(This.ReadFileIni(cFileIni,"DIRECTORY","SYSDB"))
	This.KDPStyles = this.ReadFileIni(cFileIni,"DIRECTORY","Styles")
	cMessage = ''
	FOR I = 1 TO GETWORDCOUNT(cAction,",")
		cScript 	= LOWER(GETWORDNUM(cAction,I))
		cProcedure 	= LOWER(ALLTRIM(STREXTRACT(cScript,"","(")))
		cFunction 	= ALLTRIM(STREXTRACT(cScript,"(",")")) + [(cXML,cFileIni)]
		this.lError = .F.
		cMessage = This.Scriptcontrols(cProcedure)
		IF NOT EMPTY(cMessage)
			RETURN cMessage
		ENDIF
		IF NOT cProcedure + ".fxp" $ LOWER(SET("Procedure"))
			SET PROCEDURE TO (This.kdpscripts + cProcedure + ".fxp") ADDITIVE
		ENDIF
		cMessage = &cFunction  && called function
	ENDFOR
CATCH TO oError
	this.lError = .T.
	cMessage = THIS.Error(oError.ErrorNo, oError.Procedure, oError.LineNo)
ENDTRY
IF EMPTY(cMessage) OR VARTYPE(cMessage) = "L"
	RETURN ""
ELSE
	RETURN cMessage
ENDIF
For the same object, the code for the “Error” method is
LPARAMETERS nError, cMethod, nLine

LOCAL cErrorMsg as String, cFile as String

SET TEXTMERGE ON NOSHOW
SET TEXTMERGE DELIMITERS TO <<,>>
TEXT TO cErrorMsg
======> COM SERVER ERROR REPORT ON <<TRANSFORM(DATETIME())>> <==========

CAPTURED SCRIPT ERROR INFORMATION

ErrorNo: <<TRANSFORM(nError)>>
Method:  <<cMethod>><br>
Line:    <<TRANSFORM(nLine)>>

ADDITIONAL INFORMATION FOUND FOR THE LAST VERIFIED ERROR

ErrorNo: <<TRANSFORM(IIF(this.lError,oError.ErrorNo,nError))>>
Program: <<IIF(this.lError,oError.Procedure,cMethod)>>
Line:    <<TRANSFORM(IIF(this.lError,oError.LineNo,nLine))>>
Message: <<IIF(this.lError,oError.Message,MESSAGE())>>
Source:  <<IIF(this.lError,oError.LineContents,MESSAGE(1))>>

======> END OF ERROR REPORT <==========

ENDTEXT
SET TEXTMERGE OFF
SET TEXTMERGE DELIMITERS

* Append message error to log file "OM3ERROR.log" on SysDB directory
cFile = This.KDPSysDB + "OM3ERROR.log"
= STRTOFILE(cErrorMsg,cFile,1)
* Populate COM error structure
IF INLIST(_VFP.StartMode, 3, 5)
	COMRETURNERROR(_VFP.ServerName, cErrorMsg)
ELSE
	RETURN cErrorMsg
ENDIF
When I debug the source code the TRY ENDTRY structure trap correctly the errors originated for my functions in the procedure file, but, when I compile my COM server the error returned is always the same “Syntax Error” ad the line where I invoke the function throw the use of the macro substitution.

The singularity of this problem is that when I invoke the function directly (cMessage = fAction(cXML,cFileIni) without the use of macro substitution the error is captured correctly, but when I compile, the compiler ask me where found the function “fAction” to follow the compilation, obviously, I indicate the procedure file where it is.

My concrete question is how resolve the problems indicated without lose the parametric profile of my method.

Thanks in advance for any help that the community can bring me.
Next
Reply
Map
View

Click here to load this message in the networking platform