private static void ThrowIfReturnIsError(NVMLReturnCodes returnCode) { if (returnCode == NVMLReturnCodes.Success) { return; } // https://stackoverflow.com/a/370093/528131 var errorMessagePtr = NVMLFunctions.GetErrorString(returnCode); var errorMessage = Marshal.PtrToStringAuto(errorMessagePtr); throw new Exception(string.Format("NVML Failure: {0} - {1}", returnCode, errorMessage)); }
public static extern IntPtr GetErrorString(NVMLReturnCodes returnCode);