Error Method
Class: tsbaseform
Expand/Collapse source code of procedure Error Source Code
LPARAMETERS nError, cMethod, nLine
LOCAL llHandledError, ;
      laError[AERRORARRAY], ;
      lcMessage, ;
      lnAnswer

IF THISFORM.lSetErrorOff
	THIS.lHadError = .T.
	RETURN
ENDIF

*-- Load the laError with error information
=AERROR(laError)
DO CASE
  CASE nError = 1539    && Trigger failed
    ?? CHR(7)
    *-- Use form property array to retrieve appropriate error message, 
    *-- which was initialized in the form's Init() event method.
    =MESSAGEBOX(thisform.aErrorMsg[laError[5]], ;
                MB_ICONEXCLAMATION, ;
                TASTRADE_LOC)
    *-- Restore the form if the Delete trigger failed
    IF laError[5] = DELETETRIG
      thisform.Restore()
    ENDIF
    llHandledError = .T.
  CASE nError = 1583    && Table rule failed
    *-- We assume that the appropriate error message was
    *-- displayed within the table rule. Therefore,
    *-- there is no need to handle the error here.
    IF DEBUGMODE
      *-- If we are in debug mode, put up a wait window to indicate
      *-- when table rule fails. 
      WAIT WINDOW NOWAIT TABLERULEFAIL_LOC
    ENDIF
    llHandledError = .T.

  CASE nError = 1582    && Field rule violated
    ?? CHR(7)
    lcMessage = DBGETPROP(ALIAS() + "." + laError[3], "Field", "RuleText")
    lcMessage = STRTRAN(lcMessage, '"', '')
    =MESSAGEBOX(lcMessage, ;
                MB_ICONEXCLAMATION, ;
                TASTRADE_LOC)

  OTHERWISE
    ?? CHR(7)
    lcMessage = MESSAGE() + CR + ;
            METHOD_LOC + cMethod + CR + ;
            LINENUM_LOC + ALLT(STR(nLine))
    lnAnswer = MESSAGEBOX(lcMessage, ;
                          MB_ICONSTOP + MB_ABORTRETRYIGNORE, ;
                          ERRORTITLE_LOC)
    DO CASE
      CASE lnAnswer = IDABORT
      	IF DEBUGMODE
        	SUSPEND
        ELSE
        	oApp.Cleanup
        	CANCEL
        	RETURN
		ENDIF
      CASE lnAnswer = IDRETRY
        RETRY
      OTHERWISE
        RETURN
    ENDCASE
ENDCASE

RETURN llHandledError