Nearby Connections - Fixed crash when starting the app on devices with no Bluetooth adapter

PiperOrigin-RevId: 441773811
This commit is contained in:
eidenkim
2022-04-14 08:59:23 -07:00
committed by Copybara-Service
parent d1b2437b0d
commit 3f81504dc1
@@ -123,6 +123,14 @@ Exception BluetoothServerSocket::StartListening(bool radioDiscoverable) {
LeaveCriticalSection(&critical_section_);
return {Exception::kFailed};
} catch (const winrt::hresult_error& ex) {
NEARBY_LOGS(ERROR) << __func__
<< ": Exception setting up for listen: " << ex.code()
<< ": " << winrt::to_string(ex.message());
LeaveCriticalSection(&critical_section_);
return {Exception::kFailed};
}
@@ -145,6 +153,14 @@ Exception BluetoothServerSocket::StartAdvertising() {
LeaveCriticalSection(&critical_section_);
return {Exception::kFailed};
} catch (const winrt::hresult_error& ex) {
NEARBY_LOGS(ERROR) << __func__
<< ": Exception calling StartAdvertising: " << ex.code()
<< ": " << winrt::to_string(ex.message());
LeaveCriticalSection(&critical_section_);
return {Exception::kFailed};
}