static Exception getExceptionForHResult(int hr) { // Windows version is in C++ (an OS component, really) and it defines quite a few custom error codes for various MediaEngine errors. string msg = NativeErrorMessages.customErrorMessage(hr); if (null != msg) { return(new COMException(msg, hr)); } msg = ErrorCodes.tryLookupCode(hr); if (null != msg) { return(new COMException(msg, hr)); } return(Marshal.GetExceptionForHR(hr)); }
static Exception exception(int hr) { string msg; if ((hr & NativeErrorMessages.facilityMask) == FACILITY_DECODER_DTS) { IntPtr ptr = DTS.AudioDecoder.formatMessage(hr & 0xFFFF); msg = Marshal.PtrToStringUTF8(ptr); return(new ApplicationException($"DTS decoder failed: { msg }")); } msg = NativeErrorMessages.customErrorMessage(hr); if (null != msg) { return(new ApplicationException($"DTS decoder failed: { msg }")); } ComLight.ErrorCodes.throwForHR(hr); return(null); }