mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-10 20:46:24 +00:00
Improved Exception-handling in device providers
This commit is contained in:
1 parent
68c5990ccd
commit
b300ac8451
12 files changed
+31
-15
No files matched your search
@@ -56,7 +56,7 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
protected override void InitializeSDK()
|
||||
{
|
||||
_CoolerMasterSDK.Reload();
|
||||
if (_CoolerMasterSDK.GetSDKVersion() <= 0) Throw(new RGBDeviceException("Failed to initialize CoolerMaster-SDK"));
|
||||
if (_CoolerMasterSDK.GetSDKVersion() <= 0) Throw(new RGBDeviceException("Failed to initialize CoolerMaster-SDK"), true);
|
||||
}
|
||||
|
||||
protected override IEnumerable<IRGBDevice> LoadDevices()
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace RGB.NET.Devices.CoolerMaster.Native
|
||||
#region Libary Management
|
||||
|
||||
private static IntPtr _dllHandle = IntPtr.Zero;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the SDK.
|
||||
/// </summary>
|
||||
@@ -41,6 +41,7 @@ namespace RGB.NET.Devices.CoolerMaster.Native
|
||||
if (dllPath == null) throw new RGBDeviceException($"Can't find the CoolerMaster-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'");
|
||||
|
||||
_dllHandle = LoadLibrary(dllPath);
|
||||
if (_dllHandle == IntPtr.Zero) throw new RGBDeviceException($"CoolerMaster LoadLibrary failed with error code {Marshal.GetLastWin32Error()}");
|
||||
|
||||
_getSDKVersionPointer = (GetSDKVersionPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "GetCM_SDK_DllVer"), typeof(GetSDKVersionPointer));
|
||||
_setControlDevicenPointer = (SetControlDevicePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetControlDevice"), typeof(SetControlDevicePointer));
|
||||
|
||||
Reference in new issue
Block a user