From 08a19489e8c13ae985cd356952a443a36c67956e Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Wed, 6 Nov 2024 19:55:33 +0800 Subject: [PATCH] update exception messages --- src/EcsPipeline.Builder.cs | 2 +- src/EcsRunner.cs | 2 +- src/EcsStaticMask.cs | 12 ++++++------ src/EcsWorld.pools.cs | 4 ++-- src/EcsWorld.static.cs | 2 +- src/Utils/Exceptions.cs | 8 ++++++++ 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/EcsPipeline.Builder.cs b/src/EcsPipeline.Builder.cs index 2fa6251..9e73365 100644 --- a/src/EcsPipeline.Builder.cs +++ b/src/EcsPipeline.Builder.cs @@ -214,7 +214,7 @@ namespace DCFApixels.DragonECS { case IEcsProcess system: return AddSystem_Internal(system, settedAddParams); case IEcsModule module: return AddModule_Internal(module, settedAddParams); - default: Throw.UndefinedException(); return this; + default: Throw.ArgumentException("Unsupported type"); return this; } } #endregion diff --git a/src/EcsRunner.cs b/src/EcsRunner.cs index 18fd06b..3e5ed0d 100644 --- a/src/EcsRunner.cs +++ b/src/EcsRunner.cs @@ -28,7 +28,7 @@ namespace DCFApixels.DragonECS Type targetInterface = processInterfaceType; if (runnerType.IsAbstract || runnerType.IsInterface) { - Throw.UndefinedException(); + Throw.Exception("The instance of a runner cannot be abstract."); } Type GetRunnerBaseType(Type inType) { diff --git a/src/EcsStaticMask.cs b/src/EcsStaticMask.cs index cb07dff..9c8a0db 100644 --- a/src/EcsStaticMask.cs +++ b/src/EcsStaticMask.cs @@ -278,25 +278,25 @@ namespace DCFApixels.DragonECS public Builder Exc(Type type) { return Exc(EcsTypeCodeManager.Get(type)); } public Builder Inc(EcsTypeCode typeCode) { - if (_version != _builder._version) { Throw.UndefinedException(); } + if (_version != _builder._version) { Throw.CantReuseBuilder(); } _builder.Inc(typeCode); return this; } public Builder Exc(EcsTypeCode typeCode) { - if (_version != _builder._version) { Throw.UndefinedException(); } + if (_version != _builder._version) { Throw.CantReuseBuilder(); } _builder.Exc(typeCode); return this; } public Builder Combine(EcsStaticMask mask) { - if (_version != _builder._version) { Throw.UndefinedException(); } + if (_version != _builder._version) { Throw.CantReuseBuilder(); } _builder.Combine(mask); return this; } public Builder Except(EcsStaticMask mask) { - if (_version != _builder._version) { Throw.UndefinedException(); } + if (_version != _builder._version) { Throw.CantReuseBuilder(); } _builder.Except(mask); return this; } @@ -305,7 +305,7 @@ namespace DCFApixels.DragonECS #region Build/Cancel public EcsStaticMask Build() { - if (_version != _builder._version) { Throw.UndefinedException(); } + if (_version != _builder._version) { Throw.CantReuseBuilder(); } lock (_lock) { _buildersPool.Push(_builder); @@ -314,7 +314,7 @@ namespace DCFApixels.DragonECS } public void Cancel() { - if (_version != _builder._version) { Throw.UndefinedException(); } + if (_version != _builder._version) { Throw.CantReuseBuilder(); } lock (_lock) { _buildersPool.Push(_builder); diff --git a/src/EcsWorld.pools.cs b/src/EcsWorld.pools.cs index 3320359..d9067ab 100644 --- a/src/EcsWorld.pools.cs +++ b/src/EcsWorld.pools.cs @@ -209,7 +209,7 @@ namespace DCFApixels.DragonECS if (oldPool != _nullPool) { - Throw.UndefinedException(); + Throw.Exception("Attempt to initialize a pool with the indetifier of an already existing pool."); } _pools[componentTypeID] = newPool; @@ -390,7 +390,7 @@ namespace DCFApixels.DragonECS if (_lockedPoolCount < 0) { _lockedPoolCount = 0; - Throw.UndefinedException(); + Throw.OpeningClosingMethodsBalanceError(); } _pools[ComponentTypeID].OnLockedChanged_Debug(false); } diff --git a/src/EcsWorld.static.cs b/src/EcsWorld.static.cs index b91fe0a..998fc09 100644 --- a/src/EcsWorld.static.cs +++ b/src/EcsWorld.static.cs @@ -93,7 +93,7 @@ namespace DCFApixels.DragonECS public static ref T GetForWorldUnchecked(int worldID) {// ts #if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS - if (_mapping[worldID] <= 0) { Throw.UndefinedException(); } + if (_mapping[worldID] <= 0) { Throw.ArgumentOutOfRange(); } #endif return ref _items[_mapping[worldID]]; } diff --git a/src/Utils/Exceptions.cs b/src/Utils/Exceptions.cs index 2ae2591..a6655d2 100644 --- a/src/Utils/Exceptions.cs +++ b/src/Utils/Exceptions.cs @@ -154,6 +154,14 @@ namespace DCFApixels.DragonECS.Internal { throw new Exception(); } + internal static void OpeningClosingMethodsBalanceError() + { + throw new InvalidOperationException("Error of opening - closing methods. Closing method was called more often than opening method."); + } + internal static void CantReuseBuilder() + { + throw new InvalidOperationException("Builder has already worked out, use the new builder to build again."); + } [MethodImpl(MethodImplOptions.NoInlining)] internal static void Exception(string message) {