Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sys(2030) and sys(2018)
Message
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Sys(2030) and sys(2018)
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01103076
Message ID:
01103076
Vues:
80
Hi everybody,

My colleague suggested me to take a look at sys(2030) and sys(2018) for our Error Handler. After reading Help I'm still not following, how would they help me and do they help me at all? Here is our current calling chain to report an error. Unfortunately, the erros are captured this long way:
Call Stack Level: 11
Current program: c:\mmviscollect\libs\amanagers.vct
Module or Object Name: aerrormgr.createerrorlogentry
Module or Object Source filename: c:\mmviscollect\libs\amanagers.vct
Line number in the object source file: 151
Source line contents: =astackinfo(laStack)
Call Stack Level: 10
Current program: c:\mmviscollect\libs\amanagers.vct
Module or Object Name: aerrormgr.errorhandler
Module or Object Source filename: c:\mmviscollect\libs\amanagers.vct
Line number in the object source file: 57
Source line contents: 	this.CreateErrorLogEntry()
Call Stack Level: 9
Current program: c:\mmortals\common30\libs\cforms.vct
Module or Object Name: cbaseform.error
Module or Object Source filename: c:\mmortals\common30\libs\cforms.vct
Line number in the object source file: 21
Source line contents: 	goApp.oErrorMgr.ErrorHandler(nError, cMethod, nLine, 	  tcSys16, toErrObj)
Call Stack Level: 8
Current program: c:\mmviscollect\libs\aforms.vct
Module or Object Name: mainview1.error
Module or Object Source filename: c:\mmviscollect\libs\aforms.vct
Line number in the object source file: 32
Source line contents: DODEFAULT(m.nError, m.cMethod, m.nLine, m.tcSys16, m.toErrObj)
Call Stack Level: 7
Current program: c:\mmortals\common30\libs\ccontrls.vct
Module or Object Name: mainview1.pgpatient.error
Module or Object Source filename: c:\mmortals\common30\libs\ccontrls.vct
Line number in the object source file: 47
Source line contents: THIS.Parent.Error(nError, cMethod, nLine,   tcSys16, toErrObj)
Call Stack Level: 6
Current program: c:\mmortals\common30\libs\ccontrls.vct
Module or Object Name: mainview1.pgpatient.pgactions.cntactions.error
Module or Object Source filename: c:\mmortals\common30\libs\ccontrls.vct
Line number in the object source file: 53
Source line contents: 				THIS.Parent.Parent.Error(nError, cMethod, nLine, 				  tcSys16, toErrObj)
Call Stack Level: 5
Current program: c:\mmortals\common30\libs\ccontrls.vct
Module or Object Name: mainview1.pgpatient.pgactions.cntactions.cmdpayments.error
Module or Object Source filename: c:\mmortals\common30\libs\ccontrls.vct
Line number in the object source file: 41
Source line contents: 	THIS.Parent.Error(nError, cMethod, nLine, 	  tcSys16, toErrObj)
Call Stack Level: 4
Current program: c:\mmviscollect\libs\aformspatientdemo.vct
Module or Object Name: mainview1.pgpatient.pgactions.cntactions.cmdpayments.click
So, there are lots of steps before the actual error is captured, therefore I don't see a way to find local variables of the actual program that triggered the error and the parameters of that procedure, not Error method.

Here is my current code in the CreateLogEntry method of the error handler. I would gladly accept ideas of improving it.
do case
case isnull(this.aErrorInfo[4])
	lcAError4 = '.NULL.'
case type("This.aErrorInfo[4]") = "C"
	lcAError4 = this.aErrorInfo[4]
case type("This.aErrorInfo[4]") = "N"
	lcAError4 = alltrim(str(this.aErrorInfo[4]))
otherwise
	lcAError4 = 'Unknown Error'
endcase

*------------------------------------------------
*--- AERROR() - Element 5
*--- Visual FoxPro Error
*--- Contains the .NULL. value. However, if
*--- a trigger failed (error 1539), contains
*--- one of the following numeric values:
*--- 1 - Insert trigger failed.
*--- 2 - Update trigger failed.
*--- 3 - Delete trigger failed.
*---
*--- OLE Error
*--- The null value or Character. Contains
*--- the name of the application’s Help file
*--- where more information about the error
*--- can be found if the information is
*--- available from the application; otherwise
*--- contains the null value.
*---
*--- ODBC Error
*--- Numeric. The error number from the ODBC
*--- data source.
*------------------------------------------------
do case
case isnull(this.aErrorInfo[5])
	lcAError5 = '.NULL.'
case type('This.aErrorInfo[5]') = 'N'
	do case
	case this.aErrorInfo = 1
		lcAError5 = 'Insert Trigger Failed'
	case this.aErrorInfo = 2
		lcAError5 = 'Update Trigger Failed'
	case this.aErrorInfo = 3
		lcAError5 = 'Delete Trigger Failed'
	otherwise
		lcAError5 = alltrim(str(this.aErrorInfo[5]))
	endcase
case type('This.aErrorInfo[5]') = 'C'
*--- OLE errors contain text in this column ---*
	lcAError5 = this.aErrorInfo[5]
otherwise
	lcAError5 = 'Unknown Error'
endcase

*-------------------------------------------------
*--- AERROR() - Element 6
*--- Visual FoxPro Error
*--- The .NULL. value
*---
*--- OLE Error
*--- The null value or Character. Contains the
*--- Help context ID for the appropriate Help
*--- topic if the information is available from
*--- the application; otherwise contains the
*--- null value.
*---
*--- ODBC Error
*--- Numeric. The ODBC connection handle.
*-------------------------------------------------
do case
case isnull(this.aErrorInfo[6])
	lcAError6 = '.NULL.'
case type('This.aErrorInfo[6]') = 'C'
	lcAError6 = this.aErrorInfo[6]
case type('This.aErrorInfo[6]') = 'N'
	lcAError6 = alltrim(str(this.aErrorInfo[6]))
otherwise
	lcAError6 = 'Unknown Error'
endcase

*-------------------------------------------------
*--- AERROR() - Element 7
*--- Visual FoxPro Error
*--- The .NULL. value
*---
*--- OLE Error
*--- Numeric. An OLE 2.0 exception number.
*---
*--- ODBC Error
*--- The .NULL. value
*-------------------------------------------------
do case
case isnull(this.aErrorInfo[7])
	lcAError7 = '.NULL.'
case type('This.aErrorInfo[7]') = 'N'
	lcAError7 = alltr(str(this.aErrorInfo[7]))
otherwise
	lcAError7 = 'Unknown Error'
endcase

lcAlias = this.ErrorMgrObj.GetAlias()
this.ErrorMgrObj.New()

local array laStack[1], laSessions[1], laTables[1]

local lnI, lcChainInfo, lnSessions, ;
	lcAdditionalInfo, lnCurrentSession, lcAccountNum

=astackinfo(laStack)

lcChainInfo = "The current application version is " + VERSION_LOC + ;
	" from " + transform(fdate(sys(16,1),1)) + CRLF

for lnI = alen(laStack, 1) to 1 step -1
	lcChainInfo = m.lcChainInfo + "Call Stack Level: " + ;
		alltrim(str(laStack[m.lnI,1])) + CRLF + ;
		"Current program: " + ;
		alltrim(laStack[m.lnI,2]) + CRLF + ;
		"Module or Object Name: " + ;
		alltrim(laStack[m.lnI,3]) + CRLF + ;
		"Module or Object Source filename: " + ;
		alltrim(laStack[m.lnI,4]) + CRLF + ;
		"Line number in the object source file: " + ;
		alltrim(str(laStack[m.lnI,5])) + CRLF + ;
		"Source line contents: " + ;
		alltrim(laStack[m.lnI,6]) + CRLF
next

lnSessions = asessions(laSessions)
for lnI = m.lnSessions to 1 step - 1
	=aused(laTables, m.lnI)
	if ascan(laTables,upper('v_TransPatients')) > 0
		lnCurrentSession = set("Datasession")
		set datasession to m.lnI
		lcAccountNum = v_TransPatients.cClient_Account_Number
		set datasession to m.lnCurrentSession
		exit
	endif
next

lcAdditionalInfo =  CRLF + "Parameters: " + GetParameters()

replace cUserID with iif(vartype(m.goApp)=="O", m.goApp.cUserID,""), ;
	tDateTime with datetime(), ;
	cAError1 with alltrim(str(this.aErrorInfo[1])), ;
	mAError2 with this.aErrorInfo[2], ;
	mAError3 with nvl(this.aErrorInfo[3],'.NULL.'), ;
	cAError4 with m.lcAError4, ;
	cAError5 with m.lcAError5, ;
	cAError6 with m.lcAError6, ;
	cAError7 with m.lcAError7, ;
	mCallChain with m.lcChainInfo, ;
	mEnviron with ;
	iif(not empty(m.lcAccountNum), "Account #: " + m.lcAccountNum,"") + CRLF + ;
	"Operating System: " + iif(vartype(m.goApp)=="O", ;
	m.goApp.cWindowsOS, os()) + CRLF + ;
	"Processor: " + sys(17) + CRLF + ;
	"VFP Version: " + version(1) + CRLF + ;
	"Disk Space: " + alltrim(str(diskspace())) + CRLF + ;
	"Available memory below 640K: " + sys(12) + CRLF + ;
	"Total Available memory: " + sys(1001) + CRLF + ;
	"Current directory: " + sys(5) + sys(2003) + CRLF + ;
	"FoxPro start dir: " + home() + CRLF + ;
	"Resource file: " + sys(2005) + CRLF + ;
	"Graphics card: " + sys(2006) + CRLF + ;
	"Config.SYS FILES: " + sys(2010) + CRLF + ;
	"Printer: " + sys(6) + CRLF + ;
	"Printer status: " + sys(13) + CRLF + ;
	"Network Machine: " + sys(0) + m.lcAdditionalInfo ;
	in (m.lcAlias)

this.ErrorMgrObj.save()

return
Also my colleague pointed out to the problem of capturing wrong account info if we have several main forms opened at the same time (different accounts).
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform