DragonECS-AutoInjections/src/Utils/Exceptions.cs

46 lines
1.6 KiB
C#
Raw Normal View History

2025-03-14 16:53:33 +08:00
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
2023-06-26 01:58:13 +08:00
using System.Reflection;
using System.Runtime.CompilerServices;
namespace DCFApixels.DragonECS
{
2023-12-24 18:17:43 +08:00
namespace AutoInjections.Internal
2023-06-26 01:58:13 +08:00
{
2023-06-26 02:58:53 +08:00
internal static class Throw
2023-06-26 01:58:13 +08:00
{
2023-06-26 02:58:53 +08:00
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void PropertyIsCantWrite(MemberInfo obj)
{
throw new EcsAutoInjectionException($"{obj.Name} property is cant write");
}
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void MethodIsGeneric(MemberInfo obj)
{
throw new EcsAutoInjectionException($"{obj.Name} method is Generic");
}
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void MethodArgumentsGreater1(MemberInfo obj)
{
//method X has arguments greater than 1.
throw new EcsAutoInjectionException($"{obj.Name} method Arguments != 1");
}
2024-02-25 17:36:33 +08:00
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void UndefinedException()
{
throw new Exception();
}
2023-06-26 01:58:13 +08:00
}
}
[Serializable]
public class EcsAutoInjectionException : Exception
{
public EcsAutoInjectionException() { }
public EcsAutoInjectionException(string message) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message) { }
public EcsAutoInjectionException(string message, Exception inner) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message, inner) { }
}
}