Re: Try/Catch
- Posted by dcuny Jan 11, 2015
- 5289 views
Choose a soft and graceful fail, and it will do what the filesystem does: extend the sequence and return a {} or a null.
I have asked for this for years
The idea that Euphoria just continues on merrily when it knows there was a logic error seems a fundamentally flawed idea, and I doubt many will accept it.
For things like handling strings, there are sensible defaults. But what's the correct behavior for fetching a non-existent index?
Languages built on .NET have getters and setters, so you can overwrite the default behavior for indexing. But that requires a concept of class, which Euphoria hasn't got.
Lua has an concept of fallback which can be used to extend the functionality of Lua, as well as serve as error handling. Perhaps someone on this forum has some experience with it?
So, for example, you could define what you consider sensible behavior to perform on indexing errors for your code without adversely effecting other people's code.
But even with that, there are still conditions where you would want to throw an exception.
- David