DragonECS/src/Utils/Exceptions.cs

167 lines
6.8 KiB
C#
Raw Normal View History

2023-05-30 04:32:09 +08:00
using System;
2023-06-26 01:57:50 +08:00
using System.Runtime.CompilerServices;
2023-05-30 04:32:09 +08:00
2024-02-14 03:04:05 +08:00
namespace DCFApixels.DragonECS
{
[Serializable]
public class EcsFrameworkException : Exception
{
public EcsFrameworkException() { }
public EcsFrameworkException(string message) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message) { }
public EcsFrameworkException(string message, Exception inner) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message, inner) { }
}
[Serializable]
2024-03-13 17:41:33 +08:00
public class NullInstanceException : EcsFrameworkException
{
public NullInstanceException() { }
public NullInstanceException(string message) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message) { }
public NullInstanceException(string message, Exception inner) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message, inner) { }
}
[Serializable]
2024-02-14 03:04:05 +08:00
public class EcsRunnerImplementationException : EcsFrameworkException
{
public EcsRunnerImplementationException() { }
public EcsRunnerImplementationException(string message) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message) { }
public EcsRunnerImplementationException(string message, Exception inner) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message, inner) { }
}
2024-04-28 18:36:14 +08:00
[Serializable]
public class EcsInjectionException : Exception
{
public EcsInjectionException() { }
public EcsInjectionException(string message) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message) { }
public EcsInjectionException(string message, Exception inner) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message, inner) { }
}
2024-02-14 03:04:05 +08:00
}
2024-01-26 18:59:07 +08:00
namespace DCFApixels.DragonECS.Internal
2023-05-30 04:32:09 +08:00
{
2024-01-26 18:59:07 +08:00
internal static class Throw
2023-06-26 01:57:50 +08:00
{
2024-01-26 18:59:07 +08:00
[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 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.");
}
2023-06-26 01:57:50 +08:00
2024-01-26 18:59:07 +08:00
[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)}.");
}
2023-06-26 01:57:50 +08:00
2024-01-26 18:59:07 +08:00
[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.");
}
2024-02-11 22:10:05 +08:00
[MethodImpl(MethodImplOptions.NoInlining)]
public static void World_MaskDoesntBelongWorld()
{
throw new EcsFrameworkException($"The mask doesn't belong in this world");
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static void World_EntityIsNotContained(int entityID)
{
throw new EcsFrameworkException($"An entity with identifier {entityID} is not contained in this world");
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static void World_EntityIsAlreadyСontained(int entityID)
{
throw new EcsFrameworkException($"An entity with identifier {entityID} is already contained in this world");
}
2024-02-14 21:13:00 +08:00
[MethodImpl(MethodImplOptions.NoInlining)]
public static void World_PoolAlreadyCreated()
{
throw new EcsFrameworkException("The pool has already been created.");
}
2024-03-10 21:38:43 +08:00
public static void World_WorldCantBeDestroyed()
{
throw new EcsFrameworkException("This world can't be destroyed");
}
2024-02-14 21:13:00 +08:00
2024-01-26 18:59:07 +08:00
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void Ent_ThrowIsNotAlive(entlong entity)
{
if (entity.IsNull)
2024-08-05 11:13:13 +08:00
{
2024-01-26 18:59:07 +08:00
throw new EcsFrameworkException($"The {entity} is null.");
2024-08-05 11:13:13 +08:00
}
2024-01-26 18:59:07 +08:00
else
2024-08-05 11:13:13 +08:00
{
2024-01-26 18:59:07 +08:00
throw new EcsFrameworkException($"The {entity} is not alive.");
2024-08-05 11:13:13 +08:00
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void Quiery_ArgumentDifferentWorldsException()
{
throw new ArgumentException("The groups belong to different worlds.");
2023-06-26 01:57:50 +08:00
}
2024-03-16 14:21:38 +08:00
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void ArgumentNull()
{
throw new ArgumentNullException();
}
[MethodImpl(MethodImplOptions.NoInlining)]
2024-08-05 11:13:13 +08:00
internal static void ArgumentNull(string paramName)
{
throw new ArgumentNullException(paramName);
}
[MethodImpl(MethodImplOptions.NoInlining)]
2024-03-16 14:21:38 +08:00
internal static void ArgumentOutOfRange()
{
throw new ArgumentOutOfRangeException($"index is less than 0 or is equal to or greater than Count.");
}
2024-02-03 01:12:53 +08:00
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void UndefinedException()
{
throw new Exception();
}
2024-02-24 02:26:42 +08:00
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void Exception(string message)
{
throw new Exception(message);
}
2024-04-22 17:37:37 +08:00
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void Aspect_CanOnlyBeUsedDuringInitialization(string methodName)
{
throw new InvalidOperationException($"{methodName} can only be used during field initialization and in the constructor.");
}
2023-06-26 01:57:50 +08:00
}
2024-01-26 18:59:07 +08:00
}
2023-06-26 01:57:50 +08:00