Re: Error Handling
- Posted by Igor Kachan <kinz at peterlink.ru> Mar 19, 2001
- 628 views
David Cuny wrote: > to be lazy (like me), you could just put a single > recovery routine in the > top level procedure: > > procedure main() > -- code goes here > > on error do > -- save the data file and shut down > > end procedure > > Comments? Similar "on error goto" statement was useful for me (almost just and only) when I didn't know what was wrong in my algorithms realised in the QB programs and I wanted to go some steps more in the job without immediate hard corrections. The second and last kind of these things was running the program on the unknown machine - for example, automated selection of the right graphics mode with *statement* not *function* SCREEN like this: '-------basic code on error goto 911 SCREEN 13 'if there is no this mode on machine, ' error,jump to 911 mark 'if there is this mode on machine, ' no error, jump to 912 mark goto 912 911 SCREEN 1 912 '-------end of basic code But there are no standard *functions* like i = graphics_mode(257) or i = open ("file", "wb") in that basics, same as other robust Euphoria features for debugging and running robust programs on any machine. Basics (and other *slangs* - sorry, just a bad but innocent sailor's joke just use primitive universal statement "on error goto" instead of Euphoria's concrete powerful functions. Basics *allow* errors and stop program in that places where Euphoria's function just returnes -1 or 0. What an ERROR exactly? Do you khow ? Or you don't want to know ? If *you* don't know then what will do *your program*? The *next* error instead recovery under your *unknown* commands and so on? And how long time ? Well, if you know -- then why does this bug sit in your program ? Do you see - questions, not answers ? But there may be two useful things: first - under DOS, when compiled Eu2C program runs with trace, *on real crash* not *exit on error*, for safely *closing* without damage of ctrace.out file when ctrl+alt+del (or Reset button - he he he) struck -- but only for program debugging with Beta translator on plain DOS and Beta translator debugging. :-{) Second - to save, not delete, the swap file on running off memory under plain DOS to see the content and the size of this file for more information about bug, same may be about more wide data dumping in ex.err, on each error, when hypothetical "with_wide_data_dump" option is selected in the main program file. David knows what data he wants to save, yes David? But the first thing is the OS's, and BIOS's, and machine's duty, not Euphoria's, while the second one may be a pure Euphoria's duty. I am *very lazy* programmer (see contrib.htm on the RDS site) and I don't want at all "on error do" in Euphoria, because of I know that I must to know my program as well as I can know *my* program, and Euphoria, just without ON ERROR DO or GOTO, only helps me to make my programs well documented, debugged and robust ones. Yes, I am lazy, but I don't want the old and white bugs each behind of each "on error" statement in my program or all behind the single "on error" statement in the main procedure. And Euphoria works for me and helps me. We all just don't know or don't uderstand or don't use or don't remember well enough Euphoria's simple power sometimes, I think. No ? Regards, Igor Kachan kinz at peterlink.ru