Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Global error handler question - one more try
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Global error handler question - one more try
Divers
Thread ID:
00399020
Message ID:
00399020
Vues:
58
Hi,

I've been banging my head against the wall on this one. I'm probably missing something simple but I can't quite figure it out. I started a thread on this a few days ago but thought I'd take one more shot at it.

The 'global' error handling code below is included in the start-up program for my app. Here is the problem: I put a command button on a form (formXX) with two lines of code and the first line of code contains an error - the global error handler is then called, the user is informed of the error and I then **want** the app to shut down in an orderly maner. (Note: there is code in the startup program after READ EVENTS that takes care of closing the databases, releasing the application object and any 'public' variables, etc.). However, the click event of the command button remains in the call stack - so I am not able to release that form (or any of the others for that matter). After attempting to release formXX three times, the program then continues to run the the second line of code in the commandbutton.

I've looked in the documentation, specifically 'return' (and 'return to main') and I'm still unclear as to how to remove the click event of the command button that caused the error from the call stack so that all the other forms can close and the applicatoin can exit gracefully.


* in my startup program, I have this code

ON ERROR DO errhand WITH ;
ERROR( ), MESSAGE( ), MESSAGE(1), PROGRAM( ), LINENO( )



PROCEDURE errhand
PARAMETER merror, mess, mess1, mprog, mlineno
CLEAR
oCUWS.Apperror = "General ERROR Information:"+chr(13)+chr(10)
oCUWS.Apperror = oCUWS.Apperror + "==========================="+ + chr(13)+chr(10)
oCUWS.Apperror = oCUWS.Apperror + chr(13)+chr(10)
oCUWS.Apperror = oCUWS.Apperror + 'Error number: ' + LTRIM(STR(merror))+chr(13)+chr(10)
oCUWS.Apperror = oCUWS.Apperror + 'Error message: ' + mess +chr(13)+chr(10)
oCUWS.Apperror = oCUWS.Apperror + 'Line of code with error: ' + mess1 +chr(13)+chr(10)
oCUWS.Apperror = oCUWS.Apperror + 'Line number of error: ' + LTRIM(STR(mlineno)) +chr(13)+chr(10)
oCUWS.Apperror = oCUWS.Apperror + 'Program with error: ' + mprog


* run form pError to inform user of error - form contains code to log
* information regarding the error, current environment, etc., etc.

DO FORM pERROR && form that informs user about error and that app will shut down

* code to close all open forms

if type("_screen.activeform") = "O"
if _screen.activeform.windowtype = 1 && modal form
return
endif
endif

local lnFCount
lnFCount = _screen.FormCount

for i = 1 to lnFCount
if type("_screen.ActiveForm") = "O"
if upper(_screen.ActiveForm.BaseClass) = "FORM"
_screen.ActiveForm.QueryUnload()
else
release _screen.ActiveForm
endif
endif
endfor

clear events


ENDPROC
Al Williams

Anola MB, CANADA
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform