internal void _HandleException(CoroutineException e) { if (_pCurrentInstruction != null) { _pCurrentInstruction.Stop(); _pCurrentInstruction.DecRef(); _pCurrentInstruction = null; } _pCoroutineFunc = null; _state = CoroutineState.Stopped; if (_onException != null) { _onException(this, e); } else { if (_Parent != null) { /// 'Throw up' to parent _Parent._HandleException(e); } else { CoroutineMgr._ThrowException(e); } } if (_onStopped != null) { _onStopped(this); _Parent = null; } }
static internal void _ThrowException(CoroutineException exception) { if (OnUnhandledException != null) { OnUnhandledException(exception); } else { throw exception; } }