using Arbutils.Generated;

namespace PkmnLibSharp.Utilities
{
    internal static class ResultChecker
    {
        internal static void Assert(this byte result)
        {
            switch (result)
            {
                case 0: return;
                case 1:
                    throw new NativeException("Arbutils", C.GetLastException().PtrString()!, null);
                case 2:
                    var message = Creaturelib.Generated.C.GetLastException().PtrString()!;
                    var stack = Creaturelib.Generated.C.GetLastExceptionStacktrace().PtrString();
                    throw new NativeException("CreatureLibLibrary", message, stack);
                case 4:
                    throw new NativeException("PkmnLib",
                        Pkmnlib.Generated.C.GetLastException().PtrString()!, null);
            }
        }
    }
}