Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
This looks like a typo to me
Message
 
 
To
04/01/2006 16:22:29
General information
Forum:
Visual FoxPro
Category:
The Mere Mortals Framework
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01083288
Message ID:
01083324
Views:
17
>>Hi everybody,
>>
>>I've decided to take a look into MereMortals Error Handler, because we're unsatisfied with the error log information. Here is the code from the top of the CreateErrorLogEntry method
>>
>>
>>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
>>
>>It looks like it is a typo and it should be referencing this.aErrorInfo[4] instead.
>>
>>Could you please check this method and let me know, if you think it's a typo and should be corrected?
>>
>>Thanks in advance.
>
>'Unknown Error'
>How consumer, is petrified when I see this message.
>A developer has generated an error without knowing that error is!
>After this message, as could I continue to use the application?

LOL :)

Well, this case would never happen anyway, because it could be either NULL (in most cases), or character or numeric. However, with this minor typo it was a possibility of being other types if we would have private (or global) laError and xx.

Anyway, I went ahead and made changes in our ErrorMgr subclass. Here is the new code of this method:
*---------------------- 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 lnDataSession
I'm not sure about lnDataSession games...
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform