I’m having a bit of difficulty properly utilizing the try catch blocks on the iPhone.
As I understand, the code below should not throw an exception, and doesn’t in the editor, or in system builds → properly printing the message. But in the iPhone, I’m getting unhanded exceptions (DivideByZero used here as a simple example) … Am I missing something really basic here?
The iPhone console looks like this:
→ applicationDidBecomeActive()
DivideByZeroException: Division by zero
tester.Start ()
It should…it will do nothing but throw an exception, including in the editor. Also, are you using “Fast but no exceptions”? Because that means no exceptions, including try/catch.
Any build stripping beyond ‘Strip Assemblies’ is removing the Try-Catch exception handling. (i.e. Strip Byte Code and Use Micro mscorlib). Maybe this was obvious to everyone else. I’m just a bit slow I guess. :?
Also, it seems try - catch works even with ‘No Exceptions’ selected instead of ‘Slow and Safe’, which is a bit unexpected, but a pleasant surprise perhaps for those who assumed otherwise.
Have found out the same (stripping breaks try catch) - this is quite essential to know - because it could lead to deadlock situations if an app relies on try-catch for error handling.
And as Brian posted already try-catch still works if “Fast but no exceptions” is enabled. I have nothing against this, provided the code still uses the optimized codepaths…