fix: coroutine managers now handle exceptions
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Engine.Core.Debug;
|
||||
|
||||
namespace Engine.Core;
|
||||
|
||||
public class CoroutineManager : Behaviour, IUpdate
|
||||
@@ -22,11 +24,21 @@ public class CoroutineManager : Behaviour, IUpdate
|
||||
{
|
||||
for (int i = enumerators.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (enumerators[i].Current is ICoroutineYield coroutineYield && coroutineYield.Yield())
|
||||
continue;
|
||||
try
|
||||
{
|
||||
if (enumerators[i].Current is ICoroutineYield coroutineYield && coroutineYield.Yield())
|
||||
continue;
|
||||
|
||||
if (!enumerators[i].MoveNext())
|
||||
if (!enumerators[i].MoveNext())
|
||||
enumerators.RemoveAt(i);
|
||||
}
|
||||
catch (System.Exception exception)
|
||||
{
|
||||
ILogger.Shared.LogError(this, $"Coroutine failed, removing from execution.");
|
||||
ILogger.Shared.LogException(this, exception);
|
||||
ILogger.Shared.LogTrace(exception.StackTrace);
|
||||
enumerators.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user