Verbose error messages

By J.G.Harston, July 2009
The REPORT command reports the last program error. It can make error messages more informative if you also display a message telling the user what action caused the error. A simple way to do this is to set and clear a variable around actions, and display this message as part of the error handler. For instance, the following error handler:

        doing$="":ON ERROR REPORT:PRINTdoing$:doing$=""

will display the contents of doing$ after the error message. If you then use code along the following lines:

        DEF PROCsave(F$)
        doing$=" saving """+F$+""""
        OSCLI"SAVE "+F$+" "+STR$~mem%+"+100"
        doing$=""
        ENDPROC

then if that code generates an error (eg Bad filename, Disk full, etc), then the displayed error message will be of the form:

    Disk full saving "fred"