Do exceptions/errors halt execution?

When an exception arises, does the rest of the method finish or does it basically act like a “return”?

A true C# exception will pass execution up to the next exception handler above it, so yeah, nothing else is executed.

If it’s just a red message complaint from inside Unity, mostly those just keep executing, but I won’t categorically state this; it’s different depending on what part of Unity complains.

If you expect an exception then use try/catch around just the statement that might fail and handle it. If you don’t expect an exception, just let it happen and track down and fix your bug.

Thanks for the clarification.

If you NEED stuff to happen anyway put in in finally. For example release resources, close files etc. .

1 Like