Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Error message from number
Message
 
 
À
25/01/2001 20:11:10
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00468523
Message ID:
00468909
Vues:
11
>>Hmmm... I'm guessing that if you went through all that work, then there isn't a function. :)
>>
>>Thanks, but that's far more work than simply writing a method to handle the error. The problem was that I wanted to do something like:
>>
>>ON ERROR gnErrNum = ERROR() AND gcErrMess = MESSAGE()
>>
>
>This does not do an assignment, but would assert a logical condition without any assignment, and might cause an error in itself. You could call a procedure and pass the arguments to it, doing the assignment there; I'd recommend creating an error object, perhaps as an adjunct to your app object, rather than passing around globals, which gives you better encapsulation, is open to fewer side-effects, and could easily contain code to deal with some errors in itself, controlling its response by manipulating a few properties of the error object, and providing a convenient point to distinguish between fatal and recoverable error conditions. You could then point the Error moethod of an object to it, either snagging specific errors to process in the form, passing along the parameters received at the Error method to the generic error handler object in other situations, or bypassing it totally when this is appropriate.
>
>You might look at Doug Hennig's error handler offering on his web site for a few ideas.
>
>>Which, of course, doesn't work. I was trying to avoid having to write a seperate method to assign those global variables, so I hoped to be able to just assign gnErrNum and derive the gcErrMess from that.
>>
>>It wouldn't be so bad if you could put procedures in methods. I just hate adding a method to the form that's only used in one little snippet of code. :)
>>
>
>So don't do it! Create your error object, and in the subclass that you used to create the form (you did subclass the base classes as recommended everywhere), direct the Error method to the default app Error object's handler! Now every form based on this subclass will inherit the default behavior unless you alter it further up the ladder. You could just as easily redirect to a procedure in a common file in your search path; as long as the procedure can be found at runtime, it's there.
>
>>
>>>The following code is what I have used to create a table of all error codes and messages. My errors table has the fields ErrNum (I) and Descript (200) field
>>>#Include FoxPro.h
>>>local lcTable
>>>lcTable = ""
>>>lcTable = getfile("Error Table:DBF")
>>>if empty(lcTable)
>>>   return
>>>endif
>>>close tables all
>>>use (lcTable) excl alias Errors
>>>local lnRetVal
>>>lnRetVal = MessageBox("Zap table first?", MB_ICONQUESTION + MB_YESNO, "Warning...")
>>>if lnRetVal = IDYES
>>>   zap
>>>endif
>>>set order to errnum
>>>insert into Errors ( ErrNum, Descript ) values ( 1116, "Too many windows open." )
>>>on error do SetError
>>>for i = 3000 to 5000
>>>   if i = 1116      && Too many window open error which stops execution
>>>      loop
>>>   endif
>>>   error(i)
>>>endfor
>>>on error
>>>return
>>>
>>>
>>>procedure SetError
>>>*
>>>local array laError[1]
>>>local llInsert
>>>lnRetVal = aerror(laError)
>>>if lnRetVal = 0
>>>   return
>>>endif
>>>llInsert = .t.
>>>if laError[1,1] = 1941
>>>   seek 1941
>>>   if not eof()
>>>      llInsert = .f.
>>>   endif
>>>endif
>>>if llInsert
>>>   insert into Errors ( errnum, descript ) ;
>>>      values ( laError[1,1], laError[1,2] )
>>>endif
>>>return
You may also check this site:
Developer help documentation for the latest ErrHandler is online (see
outline at http://www.ideaxchg.com/ix07/er/_sys/toccontu.htm#HelpContents).
This includes pages describing:

- the demo application
http://www.ideaxchg.com/ix07/er/erhlp003.htm
- basic usage guidelines and examples
http://www.ideaxchg.com/ix07/er/erhlp004.htm
- detailed internal specifications
http://www.ideaxchg.com/ix07/er/erhlp002.htm

If you would like to download and review the latest version of the
ErrHandler source code and demo application, you can pick up errhandl.zip
(114KB) at this URL:

http://www.ideaxchg.com/ix07/er/_zip/errhandl.zip

The ErrHandler forum posting page is at URL:

http://www.ideaxchg.com/ix08/d6post.htm

Which is Mike Asherman's Error Handler class, available for download.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform