Re: Robert Craig... One Wish Please
- Posted by Robert Craig <rds at RapidEuphoria.com> Jul 30, 2002
- 403 views
Jordah Ferguson writes: > I have only one wish i would like added to exw. The ability to call a > routine at crash time ... A global exception handler has been on my list for a long time, at least in principle. It wouldn't be hard to implement, but it raises some issues that have to be examined carefully, for example: - It would be almost useless in code translated to C, since there are very few run-time error checks. It would increase the chances that a program could not be translated properly. - It might make certain optimizations more difficult, since you couldn't be sure at compile-time that a series of statements would always be executed in a predictable order. If I wanted to free the value of a global variable early, that might be a mistake, since an exception might happen, causing a sudden jump to a routine that uses that variable, etc. - People might start to "abuse" the feature, using it for normal processing, not just exceptions, especially when some clever person reports how he speeded up his loop by 5%, by removing his test for an out-of-bounds subscript, and relying instead on the exception handler. - It might preclude doing an eventual full treatment of exceptions like C++ and other languages, where each block of statements can have its own handler. - There are issues, such as: Do we allow the exception handler to return? Do we provide the exception handler with a standardized error code so it will know what happened? etc. - If you are mainly interested in freeing resources, you should know that Euphoria flushes your files and closes them, frees .dll's, and all the memory that you allocated via allocate() is freed as well. - If you mainly just want to apologize to your user and explain what to do, you can do that with crash_message(). I had an example a while back where I might have benefited from this. I had a FreeBSD Euphoria background process running 24 hours a day and I thought it would be very useful if it could send me an email if a Euphoria exception occurred. Eventually I made it a "cron" job, started hourly, and I found that cron itself sends me an e-mail if any error messages occur when running a program. So the problem was solved. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com