For example, let's say I have an execution chain that originates from a root onEnterFrame()
event. That onEnterFrame()
calls a function, which calls another, and another etc. Somewhere deep in the call tree, I find an error and I know it is pointless to continue running any more code this frame, and I want to break the entire chain originating from the current root event, in this case, the onEnterFrame()
.
Using a single return
statement only stops the current function, not the entire chain up to the root.
I know I could manually track the successful execution of all functions, and manually return
from all functions up to the root. Also, I know I could place a try...catch
over the entire event, but I want to use try...catch
only on small parts where I know errors could occur.
I was wondering if there is another way to immediately break/exit/cancel the code execution down to the root event? (for any root event like onEnterFrame, user input, socket data, etc.)