AndrewMozley
Programmer
I have a substantial application in which there are occasionally errors – my errors! To deal with this I have a function which is invoked by an ON ERROR instruction at the start of the application.
This ‘ON ERROR’ instruction effectively calls an ErrorRoutine() function with ERROR(), MESSAGE(), PROGRAM(), LINENO()
Once there, ErrorRoutine() examines the call stack with ASTACKINFO(), finds the user name, what tables were open &c, and generates (among other things) an entry in the Errorlog.txt file with this information. So, as the developer, I can examine the Errorlog.txt file and - if necessary – make corrections to the code. This usually works fine.
However, I have been finding that sometimes The ‘ON ERROR’ routine is not being invoked : instead the user sees a message which I imagine is generated by VFP - something like :
I am trying to determine why this is happening (rather than invoking my ErrorRoutine). Unfortunately I have not been able to replicate the error myself, but the user has kindly sent me a screen shot on the last occasion.
One issue could certainly be that there are places in the application where the TRY . . . . CATCH TO . . . . . ENDTRY construct is used. And my understanding is that this takes precedence over the ON ERROR command for the time being. Would this be the only occasion where a run-time error would not cause the ErrorRoutine to be invoked?
I have noticed that when the above situation arises (an error only being reported by VFP), the ON ERROR command is still lurking in the background : because when the user – understandably ! – eventually clicks on Cancel, my ON ERROR instruction is invoked, but fails, because it says it cannot find the ErrorRoutine() function. I suppose I could help myself in this matter by including a simple instruction :
. . but then I would not be getting the benefit of the more detailed stack analysis that ErrorRoutine() provides.
However my first question to the helpful members here is “Is the TRY . . . CATCH construct the only one which temporarily over-rides the ON ERROR statement”.
Thank you
This ‘ON ERROR’ instruction effectively calls an ErrorRoutine() function with ERROR(), MESSAGE(), PROGRAM(), LINENO()
Once there, ErrorRoutine() examines the call stack with ASTACKINFO(), finds the user name, what tables were open &c, and generates (among other things) an entry in the Errorlog.txt file with this information. So, as the developer, I can examine the Errorlog.txt file and - if necessary – make corrections to the code. This usually works fine.
However, I have been finding that sometimes The ‘ON ERROR’ routine is not being invoked : instead the user sees a message which I imagine is generated by VFP - something like :
Code:
Program Error
Error reading file s:\data\xsupp.dbf
|Cancel| |Ignore| |Help|
I am trying to determine why this is happening (rather than invoking my ErrorRoutine). Unfortunately I have not been able to replicate the error myself, but the user has kindly sent me a screen shot on the last occasion.
One issue could certainly be that there are places in the application where the TRY . . . . CATCH TO . . . . . ENDTRY construct is used. And my understanding is that this takes precedence over the ON ERROR command for the time being. Would this be the only occasion where a run-time error would not cause the ErrorRoutine to be invoked?
I have noticed that when the above situation arises (an error only being reported by VFP), the ON ERROR command is still lurking in the background : because when the user – understandably ! – eventually clicks on Cancel, my ON ERROR instruction is invoked, but fails, because it says it cannot find the ErrorRoutine() function. I suppose I could help myself in this matter by including a simple instruction :
Code:
ON ERROR MESSAGEBOX(MESSAGE() + CHR(13) + PROGRAM() + CHR(13) + ;
"Line " + STR(LINENO(), 3))
. . but then I would not be getting the benefit of the more detailed stack analysis that ErrorRoutine() provides.
However my first question to the helpful members here is “Is the TRY . . . CATCH construct the only one which temporarily over-rides the ON ERROR statement”.
Thank you