Try - Catch blocks troubles (SOLVED)

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 ()

Snow Leopard + iPhone Advanced

void Start () {
		
		try{
			throw new System.DivideByZeroException();	
		}
		catch{
			Debug.Log("exception caught" + Time.time);	
		}
	
	}

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.

–Eric

Hello,
please submit bug report with sample project attached to it.

Well, yes. Exactly. The exception should be handled is what I meant.

I turned off “Fast but no exceptions”, for exactly that reason.

I’ll submit a bug report.

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.

If this is still a bug, I’ll submit the files.

Brian,
please submit bug report.
Thanks!

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…