internal static UsbError Error(ErrorCode errorCode, int ret, string description, object sender) { string win32Error = String.Empty; if (errorCode == ErrorCode.Win32Error && !UsbDevice.IsLinux && ret != 0) { win32Error = Kernel32.FormatSystemMessage(ret); } else if (errorCode == ErrorCode.MonoApiError && ret != 0) { win32Error = ((MonoUsbError)ret) + ":" + MonoUsbApi.StrError((MonoUsbError)ret); } UsbError err = new UsbError(errorCode, ret, win32Error, description, sender); lock (mLastErrorString) { mLastErrorNumber = (int)err.ErrorCode; mLastErrorString = err.ToString(); } UsbDevice.FireUsbError(sender, err); return(err); }
public static UsbError Error(ErrorCode errorCode, int ret, string description, object sender) { string win32Error = String.Empty; if (errorCode == ErrorCode.Win32Error && !UsbDevice.IsLinux && ret != 0) { win32Error = Kernel32.FormatSystemMessage(ret); } else if (errorCode == ErrorCode.MonoApiError && ret != 0) { Debug.Assert(false, "libusb-1.0 error codes should be resolved within LibUsbDotNet.LibUsb"); // win32Error = ((MonoUsbError) ret) + ":" + MonoUsbApi.StrError((MonoUsbError) ret); } UsbError err = new UsbError(errorCode, ret, win32Error, description, sender); lock (mLastErrorString) { mLastErrorNumber = (int)err.ErrorCode; mLastErrorString = err.ToString(); } UsbDevice.FireUsbError(sender, err); return(err); }