From e0ec9c310f7937b97b1f903c7f092c43e8054ea1 Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Mon, 26 Jun 2023 01:58:18 +0800 Subject: [PATCH] update exceptions --- src/Exceptions.cs | 12 ++++++++++++ src/Exceptions.cs.meta | 11 +++++++++++ src/ThreadRunner.cs | 6 +++--- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 src/Exceptions.cs create mode 100644 src/Exceptions.cs.meta diff --git a/src/Exceptions.cs b/src/Exceptions.cs new file mode 100644 index 0000000..271219f --- /dev/null +++ b/src/Exceptions.cs @@ -0,0 +1,12 @@ +using System; + +namespace DCFApixels.DragonECS +{ + public static class EcsThrowHalper_ClassicThreads + { + internal static void DoubleParallelIteration(this EcsThrowHalper _) + { + throw new InvalidOperationException("It is forbidden to start a parallel iteration before the last one is finished."); + } + } +} diff --git a/src/Exceptions.cs.meta b/src/Exceptions.cs.meta new file mode 100644 index 0000000..b658195 --- /dev/null +++ b/src/Exceptions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dc7a8620fe24fe14f892ee3f82918c94 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/ThreadRunner.cs b/src/ThreadRunner.cs index 8db4a50..7c23c5c 100644 --- a/src/ThreadRunner.cs +++ b/src/ThreadRunner.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Threading; +using static DCFApixels.DragonECS.EcsThrowHalper; namespace DCFApixels.DragonECS { @@ -61,8 +62,7 @@ namespace DCFApixels.DragonECS public static void Run(EcsThreadHandler worker, EcsReadonlyGroup entities, int minSpanSize) { #if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS - if (_isRunning) - throw new InvalidOperationException("It is forbidden to start a parallel iteration before the last one is finished."); + if (_isRunning) Throw.DoubleParallelIteration(); #endif _isRunning = true; _worker = worker; @@ -116,7 +116,7 @@ namespace DCFApixels.DragonECS { var exceptions = _catchedExceptions; _catchedExceptions = null; - throw new AggregateException("Mutiplie exceptions", exceptions); + throw new AggregateException(exceptions); } }