Created
January 11, 2018 01:05
-
-
Save iggyvolz/2b23b3bca2ed3d98f025bbff22a62df5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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