1. Error Handler
- Posted by Alessandro De Sanctis <desanctis at PRAXIS.IT> Nov 24, 1997
- 496 views
I'm a very young Euphoria programmer: the first thing I've noted is relation with prolog and LISP in list managing (I'm a prolog expert) that give to programmer a great freedom in the defintion of his structures. Unfortunately I don't understood how Euphoria implements run-time error handling, if it can do it. Is there anybody who can explain it to me? Thanks Alex
2. Re: Error Handler
- Posted by David Cuny <dcuny at DSS.CA.GOV> Nov 24, 1997
- 508 views
Hi, Alex. Perhaps you were expecting some sort of "catch" or "throw" (as in ARDI's Prolog, for example). No such luck. If there is a run-time error, Euphoria: 1. Displays an error message. 2. Creates an error file called EX.ERR. 3. Aborts. Typically, you will get a run-time error from trying using the wrong data type (an integer instead of a sequence, for example). You can control what is displayed in the error message by using crash_message(). The contents of EX.ERR will vary, depending on: 1. If you are using the Public Domain version and are less than 300 lines, and 2. If you had TRACE active. I *think* that Robert's logic is that since something bad has happened, allowing the program to continue to run will only produce worse results. In my mind, the "sudden death" error handling is perhaps one of Euphoria's remaining major weaknesses. For example, if there is an error in an editor written in Euphoria, the program will simply abort, losing all the data. People have requested that Robert add some sort of user-defined error handling be added. I was hoping that version 2.0 might include it. I'd love the option to be able to say: errorHandler = routine_id( "MyErrorHandler" ) But as of now, no such option is available. One option is to write your own versions of primary routines, and do extensive error checking. The most typical reason for my own code to fail is to request a item past the upper or lower bounds of a sequence. Did this answer your question? -- David Cuny
3. Re: Error Handler
- Posted by Daniel Berstein <danielberstein at USA.NET> Nov 24, 1997
- 517 views
>People have requested that Robert add some sort of user-defined error >handling be added. I was hoping that version 2.0 might include it. I'd love >the option to be able to say: > > errorHandler = routine_id( "MyErrorHandler" ) > >But as of now, no such option is available. One option is to write your own >versions of primary routines, and do extensive error checking. The most >typical reason for my own code to fail is to request a item past the upper >or lower bounds of a sequence. I agree with Rob's point of view, it's the programmers responsability to validate all actions. Euphoria provides us a stable enviorment that will never provide an unexpected result. Example: I made a Pascal program that sorted alphabetically, using Spanish special characters. I couldn't use standard ASCII comparison because some spanish chars are on the upper ASCII table... so I made a "virtual" ASCII table for my purposes. In that table I didn't realize people may enter numbers, but the program worked just fine. I don't know why my program does work fine with numeric inputs (I'm addressing non existant subscripts). In Euphoria I would get an error and should make the appropiate modifications. That's why I think Euphoria is great for programs prototyping... if it works in Euphoria it will work anyware!
4. Re: Error Handler
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> Nov 24, 1997
- 551 views
- Last edited Nov 25, 1997
>I'm a very young Euphoria programmer: the first thing I've noted is >relation with prolog and LISP in list managing (I'm a prolog expert) that >give to programmer a great freedom in the defintion of his structures. >Unfortunately I don't understood how Euphoria implements run-time error >handling, if it can do it. >Is there anybody who can explain it to me? If there is any kind of run time error (subscript checking, type checking, etc.) your program will be halted. There is no way to bypass this. Although I haven't seen any situation where it would be needed. In those cases that you would like error trapping (I think this is what you meant) Euphoria uses functions and they will return a certain value with certain errors. Euphoria simply doesn't need such a ugly and unpure mechanism. Ralf N. nieuwen at xs4all.nl