Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(device_info_plus): #2957 replaces throwing exception with returning default values #3445

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading