From 0356302d9085e5d69928153bff66c457faf75e4c Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Fri, 26 Jan 2024 18:59:07 +0800 Subject: [PATCH] Update Exceptions.cs --- src/Utils/Exceptions.cs | 143 ++++++++++++++++++++-------------------- 1 file changed, 72 insertions(+), 71 deletions(-) diff --git a/src/Utils/Exceptions.cs b/src/Utils/Exceptions.cs index ed4e955..b883552 100644 --- a/src/Utils/Exceptions.cs +++ b/src/Utils/Exceptions.cs @@ -2,89 +2,90 @@ using System.Runtime.CompilerServices; using System.Runtime.Serialization; -namespace DCFApixels.DragonECS + +namespace DCFApixels.DragonECS.Internal { - namespace Internal + internal static class Throw { - internal static class Throw + [MethodImpl(MethodImplOptions.NoInlining)] + internal static void ArgumentNull() { - [MethodImpl(MethodImplOptions.NoInlining)] - internal static void ArgumentNull() - { - throw new ArgumentNullException(); - } + throw new ArgumentNullException(); + } - [MethodImpl(MethodImplOptions.NoInlining)] - internal static void ConstraintIsAlreadyContainedInMask(Type type) - { - throw new EcsFrameworkException($"The {EcsDebugUtility.GetGenericTypeName(type)} constraint is already contained in the mask."); - } + [MethodImpl(MethodImplOptions.NoInlining)] + internal static void ConstraintIsAlreadyContainedInMask(Type type) + { + throw new EcsFrameworkException($"The {EcsDebugUtility.GetGenericTypeName(type)} constraint is already contained in the mask."); + } - //[MethodImpl(MethodImplOptions.NoInlining)] - //public static void ArgumentDifferentWorldsException() - //{ - // throw new ArgumentException("The groups belong to different worlds."); - //} - [MethodImpl(MethodImplOptions.NoInlining)] - internal static void ArgumentOutOfRange() - { - throw new ArgumentOutOfRangeException($"index is less than 0 or is equal to or greater than Count."); - } + //[MethodImpl(MethodImplOptions.NoInlining)] + //public static void ArgumentDifferentWorldsException() + //{ + // throw new ArgumentException("The groups belong to different worlds."); + //} + [MethodImpl(MethodImplOptions.NoInlining)] + internal static void ArgumentOutOfRange() + { + throw new ArgumentOutOfRangeException($"index is less than 0 or is equal to or greater than Count."); + } - [MethodImpl(MethodImplOptions.NoInlining)] - internal static void Group_AlreadyContains(int entityID) - { - throw new EcsFrameworkException($"This group already contains entity {entityID}."); - } - [MethodImpl(MethodImplOptions.NoInlining)] - internal static void Group_DoesNotContain(int entityID) - { - throw new EcsFrameworkException($"This group does not contain entity {entityID}."); - } - [MethodImpl(MethodImplOptions.NoInlining)] - internal static void Group_ArgumentDifferentWorldsException() - { - throw new ArgumentException("The groups belong to different worlds."); - } + [MethodImpl(MethodImplOptions.NoInlining)] + internal static void Group_AlreadyContains(int entityID) + { + throw new EcsFrameworkException($"This group already contains entity {entityID}."); + } + [MethodImpl(MethodImplOptions.NoInlining)] + internal static void Group_DoesNotContain(int entityID) + { + throw new EcsFrameworkException($"This group does not contain entity {entityID}."); + } + [MethodImpl(MethodImplOptions.NoInlining)] + internal static void Group_ArgumentDifferentWorldsException() + { + throw new ArgumentException("The groups belong to different worlds."); + } - [MethodImpl(MethodImplOptions.NoInlining)] - internal static void Pipeline_MethodCalledAfterInitialisation(string methodName) - { - throw new MethodAccessException($"It is forbidden to call {methodName}, after initialization {nameof(EcsPipeline)}."); - } - [MethodImpl(MethodImplOptions.NoInlining)] - internal static void Pipeline_MethodCalledBeforeInitialisation(string methodName) - { - throw new MethodAccessException($"It is forbidden to call {methodName}, before initialization {nameof(EcsPipeline)}."); - } - [MethodImpl(MethodImplOptions.NoInlining)] - internal static void Pipeline_MethodCalledAfterDestruction(string methodName) - { - throw new MethodAccessException($"It is forbidden to call {methodName}, after destroying {nameof(EcsPipeline)}."); - } + [MethodImpl(MethodImplOptions.NoInlining)] + internal static void Pipeline_MethodCalledAfterInitialisation(string methodName) + { + throw new MethodAccessException($"It is forbidden to call {methodName}, after initialization {nameof(EcsPipeline)}."); + } + [MethodImpl(MethodImplOptions.NoInlining)] + internal static void Pipeline_MethodCalledBeforeInitialisation(string methodName) + { + throw new MethodAccessException($"It is forbidden to call {methodName}, before initialization {nameof(EcsPipeline)}."); + } + [MethodImpl(MethodImplOptions.NoInlining)] + internal static void Pipeline_MethodCalledAfterDestruction(string methodName) + { + throw new MethodAccessException($"It is forbidden to call {methodName}, after destroying {nameof(EcsPipeline)}."); + } - [MethodImpl(MethodImplOptions.NoInlining)] - internal static void World_InvalidIncrementComponentsBalance() - { - throw new MethodAccessException("Invalid increment components balance."); - } - [MethodImpl(MethodImplOptions.NoInlining)] - internal static void World_GroupDoesNotBelongWorld() - { - throw new MethodAccessException("The Group does not belong in this world."); - } + [MethodImpl(MethodImplOptions.NoInlining)] + internal static void World_InvalidIncrementComponentsBalance() + { + throw new MethodAccessException("Invalid increment components balance."); + } + [MethodImpl(MethodImplOptions.NoInlining)] + internal static void World_GroupDoesNotBelongWorld() + { + throw new MethodAccessException("The Group does not belong in this world."); + } - [MethodImpl(MethodImplOptions.NoInlining)] - internal static void Ent_ThrowIsNotAlive(entlong entity) - { - if (entity.IsNull) - throw new EcsFrameworkException($"The {entity} is null."); - else - throw new EcsFrameworkException($"The {entity} is not alive."); - } + [MethodImpl(MethodImplOptions.NoInlining)] + internal static void Ent_ThrowIsNotAlive(entlong entity) + { + if (entity.IsNull) + throw new EcsFrameworkException($"The {entity} is null."); + else + throw new EcsFrameworkException($"The {entity} is not alive."); } } +} +namespace DCFApixels.DragonECS +{ [Serializable] public class EcsFrameworkException : Exception {