Skip to content

Instantly share code, notes, and snippets.

@iggyvolz
Created January 11, 2018 01:05
Show Gist options
  • Save iggyvolz/2b23b3bca2ed3d98f025bbff22a62df5 to your computer and use it in GitHub Desktop.
Save iggyvolz/2b23b3bca2ed3d98f025bbff22a62df5 to your computer and use it in GitHub Desktop.
using System;
class GodotError : Exception
{
public string Name { get; private set; }
public GodotError(int errorCode)
{
Name = typeof(GodotError).GetEnumName(errorCode);
}
public override string ToString()
{
return Name;
}
public static int Assert(int errorCode)
{
if (errorCode != 0)
{
throw new GodotError(errorCode);
}
return errorCode;
}
public static T Assert<T>(object[] errorList)
{
Assert((int)errorList[0]);
return (T)errorList[1];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment