HeavenStudio/Assets/Plugins/VorbisPlugin/Impl/src/NativeErrorException.cs
2022-01-30 07:03:37 -05:00

28 lines
723 B
C#

namespace OggVorbis
{
public class NativeErrorException : System.Exception
{
public NativeErrorCode NativeErrorCode { get; }
private NativeErrorException(NativeErrorCode nativeErrorCode)
: base($"Error code: {nativeErrorCode}")
{
NativeErrorCode = nativeErrorCode;
}
public override string ToString()
{
return $"{nameof(NativeErrorException)} {Message}";
}
internal static void ThrowExceptionIfNecessary(int returnValue)
{
if (returnValue == 0)
{
return;
}
throw new NativeErrorException((NativeErrorCode)returnValue);
}
}
}