Just a thought I’d like to suggest which might improve the robustness of Xojo apps by reducing the need to handle exceptions.
And I’ll apologise beforehand for suggesting this, because it was common practice in HyperTalk and SuperTalk - which don’t crash the app when a method fails for something so trivial as passing a an empty (nil) parameter.
At present in Xojo a lot of methods throw exceptions which must be handled, or the app crashes. Not negotiable. It’s annoying, pure and simple.
So every step of the way my code is constantly checking for nil, or exceptions, which I find very tedious. Sure it’s necessary to handle these cases to prevent an app crashing, but I think in many cases there is an easier way.
Let’s take Dictionaries, for example. Dictionary.Remove throws a KeyNotFoundException if the key was not found. Instead of doing that, suppose Dictionary.Remove returns a boolean result - true if it succeeded, false if it failed (ie the KeyNotFoundException).
So your code would look like:
result = Dictionary.Remove(aKey)
… and you can handle the result if you wish, or ignore it, if you don’t care (as is often the case).
But if you don’t handle the exception, the app crashes. Really dumb, in my view.
There are literally hundreds of examples where, if the Xojo syntax was changed to return a boolean result, instead of throwing an unhandled exception and crashing the app, the app won’t crash and the user could at least save their work.
And if you want to go the “extra mile”, and deal with an error, when the code returns a FALSE result, provide an ErrorCode (ie the exception) which can be interrogated and dealt with accordingly.
NB I am already subclassing many of the Xojo classes in this manner and, at the application level, it is just so much simpler.