[futurebasic] Re : [FB] ON ERROR FN

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 1999 : Group Archive : Group : All Groups

From: "jonathan" <jonathan@...>
Date: Sat, 01 May 1999 17:08:57 +0200
> I am using ON ERROR FN doerrors to trap disk errors like file busy
> (system error -49 & -54). I am having difficulty figuring out where FB
> resumes processing  after  LOCAL FN doerrors  displays an error message
> in a window, sets ERROR=_noerr and SYSERROR=_noerr, and then exits the
> FN. ON ERROR FN is set only in the main program, but errors can occur in
> main program Local Fn's or in include files.
>
> It would seem that FB should always resume processing at the line of
> code immediately following the offending statement (in this case OPEN
> "R".....), but it doesn't .
>
> Anyone know where FB resumes processing after a disk error is
> encountered & handled with ON ERROR FN?

I would suppose that FB deals with this (and all other stuff that we
'install' at startup using ON xxxxx FN doXXXXX) at HANDLEEVENTS. That is the
event is treated and then continues jumping to the different handlers for
the different type of events. However there may be a point that ON ERROR is
special kind that needs immediate treatment.

i can see 2 strategies here:

1
Put a TRON BREAK in your error treatment FN.
provoke the type of error that you're treating (ie, eject a disk in mid
treatment, or set it to busy with something else...) then follow the program
flow in DeBugII to see where it picks up.

2
I don't use ON ERROR, I detect the error in the FN and return a result.
This result eventually filters through to a FN that is called in my main
event loop:

DO
 HANDLEEVENTS
 FN doControl( @ar)
UNTIL whatEver

In doControl, the error state is treated in one of 2 ways:
- it was a 'fatal' error, inform the user and prepare the app to bail out as
respectably as possible
- it was a 'non-fatal' error, inform the user how she can set things back
shipshape.

'ar' is a record that I use to contain all information about the
application, it avoids me having dozens of globals to deal with.

HTH
jonathan