>>DO CASE >> CASE ISNULL(This.aErrorInfo[4]) >> lcAError4 = '.NULL.' >> CASE TYPE("laError[xx,4]") = "C" >> lcAError4 = This.aErrorInfo[4] >> CASE type("laError[xx,4]") = "N" >> lcAError4 = ALLTRIM(STR(This.aErrorInfo[4])) >> OTHERWISE >> lcAError4 = 'Unknown Error' >>ENDCASE>>
*---------------------- Location Section ------------------------ * Library: Amanagers.vcx * Class: Aerrormgr * Method: Createerrorlogentry() *----------------------- Usage Section -------------------------- *) Description: *) * Scope: Public * Parameters: *$ Usage: *$ * Returns: *--------------------- Maintenance Section ---------------------- * Change Log: * CREATED 01/04/2006 - NN * MODIFIED *---------------------------------------------------------------- LOCAL lnDataSession, lcAError4, lcAError5, lcAError6, lcAError7, ; lcAlias lnDataSession = SET('DataSession') SET DATASESSION TO lnDataSession *------------------------------------------------ *--- In the following code, we have taken into *--- account OLE, ODBC and regular VFP errors *--- AErrors 1-3 are similar and are handled *--- directly within the INSERT statement. *------------------------------------------------ *---------------------------------------------- *--- AERROR() - Element 4 *--- VFP Errors *--- Contains the .NULL. value. However, as *--- appropriate, contains the number of the *--- work area in which the error occurred. *--- *--- OLE Errors *--- Character. The Application name. For *--- example, Microsoft Excel. *--- *--- ODBC Errors *--- Character. The current ODBC SQL state. *---------------------------------------------- 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 *---------------------------------------------- *--- Get the complete program execution path *---------------------------------------------- *!* LOCAL lnCount *!* lnCount = 1 lcAlias = This.ErrorMgrObj.GetAlias() This.ErrorMgrObj.New() LOCAL ARRAY laStack[1] LOCAL lnI, lcChainInfo #define CRLF CHR(13) + CHR(10) ASTACKINFO(laStack) *!* Array Element Description *!* 1 Call Stack Level *!* *!* 2 Current program filename *!* *!* 3 Module or Object name *!* *!* 4 Module or Object Source filename *!* *!* 5 Line number in the object source file *!* *!* 6 Source line contents lcChainInfo = "" FOR lnI = 1 to ALEN(laStack, 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 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 ; "Operating System: " + IIF(varTYPE(m.goApp)=="O", m.goApp.cWindowsOS, OS()) + CRLF + ; "Processor: " + SYS(17) + CRLF + ; "VFP Version: " + VERSION(1) + CRLF + ; "Disk Space: " + ALLTR(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) ; IN (m.lcAlias) This.ErrorMgrObj.Save() SET DATASESSION TO lnDataSessionI'm not sure about lnDataSession games...