Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error handler within a dll
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00597613
Message ID:
00597618
Views:
15
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
Previous
Reply
Map
View

Click here to load this message in the networking platform