Skip to content

Commit

Permalink
[KKS] Add more logging to UniTask exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Nov 25, 2021
1 parent 3dda4db commit 22af4d4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/KKSAPI/KoikatuAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,14 @@ public static void Init()
private static void LogUnitaskException(System.Runtime.ExceptionServices.ExceptionDispatchInfo __result)
{
if (__result != null)
UnityEngine.Debug.LogWarning("Exception has been thrown inside a UniTask, it might crash the task!\n" + __result.SourceException);
UnityEngine.Debug.LogWarning("Exception has been thrown inside a UniTask, it might crash the task if not caught! (ExceptionHolder.GetException)\n" + __result.SourceException);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskMethodBuilder), nameof(Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskMethodBuilder.SetException))]
private static void LogUnitaskException(Exception exception)
{
if (exception != null && !(exception is OperationCanceledException))
UnityEngine.Debug.LogWarning("Exception has been thrown inside a UniTask, it might crash the task if not caught! (AsyncUniTaskMethodBuilder.SetException)\n" + exception);
}
}
}
Expand Down

0 comments on commit 22af4d4

Please sign in to comment.