From e23214900853b69f32afba2cbd8c5f66c5fdbaec Mon Sep 17 00:00:00 2001 From: Aaron Yu Date: Thu, 23 Mar 2023 10:41:03 -0700 Subject: [PATCH] Add catch(...) exceptions to catch unknown exceptions in NC bluetooth adapter PiperOrigin-RevId: 518902703 --- .../implementation/windows/bluetooth_adapter.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/platform/implementation/windows/bluetooth_adapter.cc b/internal/platform/implementation/windows/bluetooth_adapter.cc index 6afccb28..026083dc 100644 --- a/internal/platform/implementation/windows/bluetooth_adapter.cc +++ b/internal/platform/implementation/windows/bluetooth_adapter.cc @@ -96,6 +96,8 @@ BluetoothAdapter::BluetoothAdapter() : windows_bluetooth_adapter_(nullptr) { } catch (const winrt::hresult_error &error) { NEARBY_LOGS(ERROR) << __func__ << ": WinRT exception: " << error.code() << ": " << winrt::to_string(error.message()); + } catch (...) { + NEARBY_LOGS(ERROR) << __func__ << ": unknown error."; } } @@ -154,6 +156,9 @@ bool BluetoothAdapter::SetStatus(Status status) { << winrt::to_string(ex.message()); return false; + } catch (...) { + NEARBY_LOGS(ERROR) << __func__ << ": unknown error."; + return false; } NEARBY_LOGS(INFO) << __func__ << ": Successfully set the radio state to " @@ -180,6 +185,9 @@ bool BluetoothAdapter::IsEnabled() const { NEARBY_LOGS(ERROR) << __func__ << ": exception:" << ex.code() << ": " << winrt::to_string(ex.message()); return false; + } catch (...) { + NEARBY_LOGS(ERROR) << __func__ << ": unknown error."; + return false; } } @@ -202,6 +210,9 @@ bool BluetoothAdapter::IsExtendedAdvertisingSupported() const { NEARBY_LOGS(ERROR) << __func__ << ": exception:" << ex.code() << ": " << winrt::to_string(ex.message()); return false; + } catch (...) { + NEARBY_LOGS(ERROR) << __func__ << ": unknown error."; + return false; } } @@ -727,6 +738,9 @@ std::string BluetoothAdapter::GetMacAddress() const { NEARBY_LOGS(ERROR) << __func__ << ": exception:" << ex.code() << ": " << winrt::to_string(ex.message()); return ""; + } catch (...) { + NEARBY_LOGS(ERROR) << __func__ << ": unknown error."; + return ""; } }