Exceptions - ParkinT/RubyMotion_Life GitHub Wiki
Exceptions in RubyMotion
Here is a great explanation of some of the important details related to exceptions and exception handling in RubyMotion directly from Laurent.
- Ruby exceptions are implemented as C++ exceptions in the runtime. So yes, there are fairly expensive to throw and catch. However, these are often called zero-cost exceptions because "try" scopes are almost free to enter (the runtime does not need to setup anything before entering a begin block).
- It's really better not to use exceptions at all, since they can dramatically impact the performances of an app. However, if you use exceptions for... well, exceptional code paths (right before crashing the app for example), I guess it should be okay. But it's better to avoid them when doing simple error checking.
- You can follow the Ruby principles here (I guess you need to subclass Exception but I'm not sure.)
Regarding Exception Logging, Laurent says:
I changed RubyMotion to always log exceptions via NSLog(), and this can be controlled using the Exception.log_exceptions variable (true by default, can be set to false to stop logging).