Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ON ERROR question
#2
Right, you can use ON ERROR inside SU/FUNC to designate another handler, but the handler label must be in the main part of the program.

I like that behavior, as it provides an easy mechanism to cleanly emergency exit your program. I use this a lot in my GuiTools Framework:

The SUB InternalErrHandler switches to an simple internal trap handler just saving the error for later flow control, SUB UserErrHandler switches back to the regular user handler with message box popup.

More than that I've an "IF _EXIT THEN ERROR 1000" in every essential loop, so when the user closes the program in a sudden unexpected moment, then ERROR 1000 jumps directly into the active error handler no worries about how deep in the SUB/FUNC calling stack or nested loops the program is right now. The error handlers notice error number 1000 as immediate exit request and RESUME to the label "emergencyExit:" where a proper cleanup procedure is done before the program finally ends with SYSTEM.
Reply


Messages In This Thread
ON ERROR question - by TerryRitchie - 08-16-2024, 07:16 PM
RE: ON ERROR question - by RhoSigma - 08-16-2024, 07:51 PM
RE: ON ERROR question - by Pete - 08-16-2024, 08:29 PM
RE: ON ERROR question - by TerryRitchie - 08-16-2024, 09:16 PM
RE: ON ERROR question - by Pete - 08-16-2024, 09:38 PM
RE: ON ERROR question - by TerryRitchie - 08-16-2024, 09:43 PM
RE: ON ERROR question - by Pete - 08-16-2024, 09:54 PM
RE: ON ERROR question - by TerryRitchie - 08-16-2024, 10:00 PM
RE: ON ERROR question - by Pete - 08-16-2024, 10:19 PM
RE: ON ERROR question - by SMcNeill - 08-16-2024, 10:41 PM
RE: ON ERROR question - by RhoSigma - 08-16-2024, 10:58 PM
RE: ON ERROR question - by TerryRitchie - 08-17-2024, 02:53 AM
RE: ON ERROR question - by RhoSigma - 08-17-2024, 02:10 PM
RE: ON ERROR question - by TerryRitchie - 08-17-2024, 06:59 PM
RE: ON ERROR question - by Pete - 08-16-2024, 11:23 PM
RE: ON ERROR question - by Pete - 08-17-2024, 04:24 AM
RE: ON ERROR question - by luke - 08-17-2024, 11:58 AM
RE: ON ERROR question - by eoredson - 09-02-2024, 04:39 AM
RE: ON ERROR question - by Pete - 08-19-2024, 03:15 AM



Users browsing this thread: 18 Guest(s)