DragonECS-Graphs/src/Utils/Exceptions.cs

74 lines
2.3 KiB
C#
Raw Normal View History

2025-03-14 16:53:51 +08:00
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
2024-03-16 13:54:50 +08:00
using System.Collections.Generic;
2024-01-26 21:56:03 +08:00
using System.Runtime.CompilerServices;
2023-06-22 03:54:20 +08:00
2024-03-16 13:54:50 +08:00
namespace DCFApixels.DragonECS.Graphs.Internal
2024-01-26 21:56:03 +08:00
{
internal static class Throw
{
2024-03-16 13:54:50 +08:00
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void RelationAlreadyExists()
{
throw new EcsRelationException("This relation already exists.");
}
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void UndefinedRelationException()
{
throw new EcsRelationException();
}
2024-01-26 21:56:03 +08:00
[MethodImpl(MethodImplOptions.NoInlining)]
2024-11-17 13:36:14 +08:00
internal static void ArgumentNull(string paramName)
2024-01-26 21:56:03 +08:00
{
2024-11-17 13:36:14 +08:00
throw new ArgumentNullException(paramName);
2024-01-26 21:56:03 +08:00
}
2024-01-31 04:25:48 +08:00
[MethodImpl(MethodImplOptions.NoInlining)]
2024-03-16 13:54:50 +08:00
internal static void ArgumentOutOfRange()
{
throw new ArgumentOutOfRangeException($"index is less than 0 or is equal to or greater than Count.");
}
[MethodImpl(MethodImplOptions.NoInlining)]
2024-01-31 04:25:48 +08:00
internal static void UndefinedException()
{
throw new Exception();
}
[MethodImpl(MethodImplOptions.NoInlining)]
2024-03-16 13:54:50 +08:00
internal static void Exception(string message)
2024-01-31 04:25:48 +08:00
{
2024-03-16 13:54:50 +08:00
throw new Exception(message);
2024-01-31 04:25:48 +08:00
}
[MethodImpl(MethodImplOptions.NoInlining)]
2024-03-16 13:54:50 +08:00
internal static void ArgumentException(string message)
2024-01-31 04:25:48 +08:00
{
2024-03-16 13:54:50 +08:00
throw new ArgumentException(message);
2024-01-31 04:25:48 +08:00
}
2024-02-03 21:37:11 +08:00
[MethodImpl(MethodImplOptions.NoInlining)]
2024-03-16 13:54:50 +08:00
internal static void KeyNotFound()
2024-02-03 21:37:11 +08:00
{
2024-03-16 13:54:50 +08:00
throw new KeyNotFoundException();
2024-02-03 21:37:11 +08:00
}
2024-11-17 13:36:14 +08:00
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void Quiery_ArgumentDifferentWorldsException()
{
throw new ArgumentException("The groups belong to different worlds.");
}
2024-01-26 21:56:03 +08:00
}
}
2023-06-22 03:54:20 +08:00
namespace DCFApixels.DragonECS
{
[Serializable]
public class EcsRelationException : Exception
{
public EcsRelationException() { }
public EcsRelationException(string message) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message) { }
public EcsRelationException(string message, Exception inner) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message, inner) { }
}
}