public static void Assert(this MpReturnCode code) { switch (code) { case MpReturnCode.Success: return; case MpReturnCode.Aborted: { throw new MediaPipeException("MediaPipe Aborted, refer glog files for more details"); } case MpReturnCode.StandardError: { throw new MediaPipePluginException($"Exception is thrown in Unmanaged Code"); } case MpReturnCode.UnknownError: { throw new MediaPipePluginException($"Unknown exception is thrown in Unmanaged Code"); } case MpReturnCode.Unset: { // Bug throw new MediaPipePluginException($"Failed to call a native function, but the reason is unknown"); } default: { throw new MediaPipePluginException($"Failed to call a native function, but the reason is undefined"); } } }
private T ValueOrFormatException <T>(MpReturnCode code, T value) { try { code.Assert(); return(value); } catch (MediaPipeException) { throw new FormatException($"Invalid image format: {Format()}"); } }
public static void Assert(this MpReturnCode code) { switch (code) { case MpReturnCode.Success: return; case MpReturnCode.Aborted: { throw new MediaPipeException("MediaPipe Aborted, refer glog files for more details"); } default: { throw new MediaPipePluginException($"Failed to call a native function (code={code}"); } } }