From 7e47be374b410fc57b8c9f1c767aee45d6cfa355 Mon Sep 17 00:00:00 2001 From: Rohit Sangwan Date: Mon, 4 Mar 2024 15:19:47 +0530 Subject: [PATCH] Fix windows release build compilation (#16) --- windows/src/helper/utils.h | 5 ++--- windows/src/universal_ble_plugin.cpp | 16 ++++++---------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/windows/src/helper/utils.h b/windows/src/helper/utils.h index 0a32d10..4d622cf 100644 --- a/windows/src/helper/utils.h +++ b/windows/src/helper/utils.h @@ -26,7 +26,6 @@ namespace universal_ble std::string to_uuidstr(winrt::guid guid); - /// To call async functions synchronously template static auto async_get(async_t const &async) @@ -43,9 +42,9 @@ namespace universal_ble { throw FlutterError(winrt::to_string(err.message())); } - catch (const std::exception &err) + catch (...) { - throw FlutterError(err.what()); + throw FlutterError("Unknown error"); } } diff --git a/windows/src/universal_ble_plugin.cpp b/windows/src/universal_ble_plugin.cpp index d586b96..58c1752 100644 --- a/windows/src/universal_ble_plugin.cpp +++ b/windows/src/universal_ble_plugin.cpp @@ -785,10 +785,6 @@ namespace universal_ble std::cout << "WriteValueLog: " << winrt::to_string(err.message()) << " ErrorCode: " << std::to_string(errorCode) << std::endl; result(FlutterError(std::to_string(errorCode), winrt::to_string(err.message()))); } - catch (const std::exception &err) - { - result(FlutterError("WriteFailed", err.what())); - } catch (...) { result(FlutterError("WriteFailed", "Unknown error")); @@ -904,7 +900,8 @@ namespace universal_ble flutter::EncodableList results = flutter::EncodableList(); for (auto &&deviceInfo : devices) { - try{ + try + { BluetoothLEDevice device = co_await BluetoothLEDevice::FromIdAsync(deviceInfo.Id()); auto deviceId = _mac_address_to_str(device.BluetoothAddress()); // Filter by services @@ -932,7 +929,10 @@ namespace universal_ble universalScanResult.set_name(winrt::to_string(deviceInfo.Name())); universalScanResult.set_is_paired(deviceInfo.Pairing().IsPaired()); results.push_back(flutter::CustomEncodableValue(universalScanResult)); - }catch(...){ } + } + catch (...) + { + } } result(results); } @@ -942,10 +942,6 @@ namespace universal_ble std::cout << "GetConnectedDeviceLog: " << winrt::to_string(err.message()) << " ErrorCode: " << std::to_string(errorCode) << std::endl; result(FlutterError(std::to_string(errorCode), winrt::to_string(err.message()))); } - catch (const std::exception &err) - { - result(FlutterError(err.what())); - } catch (...) { std::cout << "Unknown error GetConnectedDevicesAsync" << std::endl;