Update Exceptions.cs

This commit is contained in:
Mikhail 2024-01-26 18:59:07 +08:00
parent 9ae92c7cdf
commit 0356302d90

View File

@ -2,89 +2,90 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.Serialization; 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)] throw new ArgumentNullException();
internal static void ArgumentNull() }
{
throw new ArgumentNullException();
}
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
internal static void ConstraintIsAlreadyContainedInMask(Type type) internal static void ConstraintIsAlreadyContainedInMask(Type type)
{ {
throw new EcsFrameworkException($"The {EcsDebugUtility.GetGenericTypeName(type)} constraint is already contained in the mask."); throw new EcsFrameworkException($"The {EcsDebugUtility.GetGenericTypeName(type)} constraint is already contained in the mask.");
} }
//[MethodImpl(MethodImplOptions.NoInlining)] //[MethodImpl(MethodImplOptions.NoInlining)]
//public static void ArgumentDifferentWorldsException() //public static void ArgumentDifferentWorldsException()
//{ //{
// throw new ArgumentException("The groups belong to different worlds."); // throw new ArgumentException("The groups belong to different worlds.");
//} //}
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
internal static void ArgumentOutOfRange() internal static void ArgumentOutOfRange()
{ {
throw new ArgumentOutOfRangeException($"index is less than 0 or is equal to or greater than Count."); throw new ArgumentOutOfRangeException($"index is less than 0 or is equal to or greater than Count.");
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
internal static void Group_AlreadyContains(int entityID) internal static void Group_AlreadyContains(int entityID)
{ {
throw new EcsFrameworkException($"This group already contains entity {entityID}."); throw new EcsFrameworkException($"This group already contains entity {entityID}.");
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
internal static void Group_DoesNotContain(int entityID) internal static void Group_DoesNotContain(int entityID)
{ {
throw new EcsFrameworkException($"This group does not contain entity {entityID}."); throw new EcsFrameworkException($"This group does not contain entity {entityID}.");
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
internal static void Group_ArgumentDifferentWorldsException() internal static void Group_ArgumentDifferentWorldsException()
{ {
throw new ArgumentException("The groups belong to different worlds."); throw new ArgumentException("The groups belong to different worlds.");
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
internal static void Pipeline_MethodCalledAfterInitialisation(string methodName) internal static void Pipeline_MethodCalledAfterInitialisation(string methodName)
{ {
throw new MethodAccessException($"It is forbidden to call {methodName}, after initialization {nameof(EcsPipeline)}."); throw new MethodAccessException($"It is forbidden to call {methodName}, after initialization {nameof(EcsPipeline)}.");
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
internal static void Pipeline_MethodCalledBeforeInitialisation(string methodName) internal static void Pipeline_MethodCalledBeforeInitialisation(string methodName)
{ {
throw new MethodAccessException($"It is forbidden to call {methodName}, before initialization {nameof(EcsPipeline)}."); throw new MethodAccessException($"It is forbidden to call {methodName}, before initialization {nameof(EcsPipeline)}.");
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
internal static void Pipeline_MethodCalledAfterDestruction(string methodName) internal static void Pipeline_MethodCalledAfterDestruction(string methodName)
{ {
throw new MethodAccessException($"It is forbidden to call {methodName}, after destroying {nameof(EcsPipeline)}."); throw new MethodAccessException($"It is forbidden to call {methodName}, after destroying {nameof(EcsPipeline)}.");
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
internal static void World_InvalidIncrementComponentsBalance() internal static void World_InvalidIncrementComponentsBalance()
{ {
throw new MethodAccessException("Invalid increment components balance."); throw new MethodAccessException("Invalid increment components balance.");
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
internal static void World_GroupDoesNotBelongWorld() internal static void World_GroupDoesNotBelongWorld()
{ {
throw new MethodAccessException("The Group does not belong in this world."); throw new MethodAccessException("The Group does not belong in this world.");
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
internal static void Ent_ThrowIsNotAlive(entlong entity) internal static void Ent_ThrowIsNotAlive(entlong entity)
{ {
if (entity.IsNull) if (entity.IsNull)
throw new EcsFrameworkException($"The {entity} is null."); throw new EcsFrameworkException($"The {entity} is null.");
else else
throw new EcsFrameworkException($"The {entity} is not alive."); throw new EcsFrameworkException($"The {entity} is not alive.");
}
} }
} }
}
namespace DCFApixels.DragonECS
{
[Serializable] [Serializable]
public class EcsFrameworkException : Exception public class EcsFrameworkException : Exception
{ {