Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to catch an error within an error handler in VFP6
Message
 
À
10/11/2004 19:21:08
James Chan
Objectmastery Pty Ltd
Hawthorn, Australie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00959865
Message ID:
00960302
Vues:
9
My current Error Handler is like this:
ON ERROR ErrorHandler(ERROR(),PROGRAM(),LINENO())



FUNCTION ErrorHandler(nError,cMethod,nLine)

   LOCAL lcErrorMsg,lcCodeLineMsg
   WAIT CLEAR
   lcErrorMsg    = MESSAGE()+CHR(13)+CHR(13)
   lcErrorMsg    = lcErrorMsg+"Method:    "+cMethod
   lcCodeLineMsg = MESSAGE(1)

   IF BETWEEN(nLine,1,10000) AND NOT lcCodeLineMsg="..."
      lcErrorMsg=lcErrorMsg+CHR(13)+"Line:         "+ALLTRIM(STR(nLine))
      IF NOT EMPTY(lcCodeLineMsg)
         lcErrorMsg=lcErrorMsg+CHR(13)+CHR(13)+lcCodeLineMsg
      ENDIF
   ENDIF

   lcErrorMsg = lcErrorMsg + CHR(13) + CHR(13) + "Error ¹ " + STR(nError)
   DO CASE
      CASE nerror = 1961
      CASE INLIST(nerror, 3, 1705) .AND. "PACKFILE"  $ UPPER(cMethod)
      CASE INLIST(nerror,2034, 2035)
           MessageBox("Invalid Date")
           RETURN .t.

      CASE nerror = 109
           MessageBox("Current record is locked somewhere else")
           RETURN .t.

   OTHERWISE
        IF MessageBox(lcErrorMsg,1+48) == 1
           RETURN .t.
        ELSE
           CLEAR EVENTS
           _screen.Picture = ""
           CLEAR EVENTS
           TRY
             CLEAR ALL
           CATCH
           ENDTRY
           ON ERROR
           ON SHUTDOWN
           IF _VFP.StartMode # 0
              QUIT
           ELSE
              RETURN TO MASTER
           ENDIF
           RETURN .f.
        ENDIF
   ENDCASE

RETURN .t.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform