Skip to content

Commit

Permalink
fix: #2957 replaces throwing exception with returning default values (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelbeltran authored Jan 28, 2025
1 parent 743bec6 commit 084730f
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ library device_info_plus_windows;

import 'dart:ffi';
import 'dart:typed_data';
import 'dart:developer' as developer;

import 'package:device_info_plus_platform_interface/device_info_plus_platform_interface.dart';
import 'package:ffi/ffi.dart';
Expand Down Expand Up @@ -124,8 +125,8 @@ class DeviceInfoPlusWindowsPlugin extends DeviceInfoPlatform {
if (result != 0) {
return memoryInKilobytes.value ~/ 1024;
} else {
final error = GetLastError();
throw WindowsException(HRESULT_FROM_WIN32(error));
developer.log('Failed to get system memory', error: GetLastError());
return 0;
}
} finally {
free(memoryInKilobytes);
Expand All @@ -149,7 +150,8 @@ class DeviceInfoPlusWindowsPlugin extends DeviceInfoPlatform {
if (result != 0) {
return lpBuffer.toDartString();
} else {
throw WindowsException(HRESULT_FROM_WIN32(GetLastError()));
developer.log('Failed to get computer name', error: GetLastError());
return "";
}
} finally {
free(lpBuffer);
Expand All @@ -167,7 +169,8 @@ class DeviceInfoPlusWindowsPlugin extends DeviceInfoPlatform {
if (result != 0) {
return lpBuffer.toDartString();
} else {
throw WindowsException(HRESULT_FROM_WIN32(GetLastError()));
developer.log('Failed to get user name', error: GetLastError());
return "";
}
} finally {
free(pcbBuffer);
Expand Down

0 comments on commit 084730f

Please sign in to comment.