Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Error handler within a dll
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00597613
Message ID:
00597618
Vues:
16
Robert,

You don't need to setup an error handler. Each class has an error event which fires when an error occurs in your class. You could set a couple of properties that allow you to query if an error has occurred. Try something like the following:
DEFINE CLASS myClass
  lError = .f.
  lErrorTrap = .f.

PROCEDURE Error
   *-- update error property
   This.lError = .t.

   *-- check if an error trap has been set. If yes, bail out
   *-- since we were expecting an error and most probably want
   *-- to handle it in the method it occurred
   IF This.lErrorTrap
     *-- reset error trap
     This.lErrorTrap = .f.
     *-- do nothing
     RETURN
   ENDIF

   *-- handle error (log, inform user, etc)

   RETURN
ENDPROC

PROCEDURE MyMethod
  *-- before doing some code that might cause an error,
  *-- setup error trap
  This.lErrorTrap = .t.
  
  *-- do something
  USE SomeTable EXCLUSIVE

  *-- check if error occurred
  IF This.lError
    *-- handle error
  ENDIF

  RETURN
ENDPROC

ENDDEFINE
You find some useful information on error handling on the wiki. Particulary useful is Doug Hennigs article http://fox.wikis.com/wc.dll?Wiki~DougHennigsErrorHandlingPaper~VFP

HTH
Daniel
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform