Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Error handling
Message
De
29/02/2000 10:08:37
 
 
À
29/02/2000 04:42:31
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Titre:
Divers
Thread ID:
00338981
Message ID:
00339088
Vues:
29
Hi Jan.

>If have general function with an special error handling
>with de on error command i create the handling
>
>If the function is called from a form the error handling from
>the form is used. How can i prevent this.

As you've seen, if a PRG is called from an object and that object has code in its Error method, the Error method is called when an error occurs in the PRG rather than any ON ERROR the PRG sets up. The solution is to change the Error method to see if any ON ERROR routine has been set up, and if so, call it. I have code like the following in the Error method of all my base classes (this is stripped down for illustrative purposes):
aerror(laError)

* A global error handler is in effect, so let's pass the error on to it.
* Replace certain parameters passed to the error handler (the name of the
* program, the error number, the line number, the message, and SYS(2018)) with
* the appropriate values.

if not empty(on('ERROR'))
    lcError = upper(on('ERROR'))
    lcError = strtran(lcError, 'SYS(16)',   '"' + tcMethod + '"')
    lcError = strtran(lcError, 'PROGRAM()', '"' + tcMethod + '"')
    lcError = strtran(lcError, ',ERROR()',  ',tnError')
    lcError = strtran(lcError, ' ERROR()',  ' tnError')
    lcError = strtran(lcError, 'LINENO()',  'tnLine')
    lcError = strtran(lcError, 'MESSAGE()', 'laError[2]')
    lcError = strtran(lcError, 'SYS(2018)', 'laError[3]')

* If the error handler is called with DO, macro expand it and assume the return
* value is "CONTINUE". If the error handler is called as a function (such as an
* object method), call it and grab the return value if there is one.

    if left(lcError, 3) = 'DO ' or '=' $ lcError
        &lcError
        lcReturn = 'CONTINUE'
    else
        lcReturn = &lcError
    endif left(lcError, 3) = 'DO ' ...
For more details, download the Error Handling paper from the Technical Papers page of Stonefield's Web site.

Doug
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform