QNetworkInformation[Win]: Improve WinRT exceptions handling
- handle only winrt::hresult_error exceptions, as this is the only reported cases, so we don't need ellipsis there - print relevant warnings Pick-to: 6.5 Change-Id: Ibf18a7eab7862e2c20f5729545387ddc7ca42952 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
ca978e2c12
commit
f6908c4f71
@ -203,7 +203,9 @@ QNetworkInformation::TransportMedium getTransportMedium(const ConnectionProfile
|
||||
NetworkAdapter adapter(nullptr);
|
||||
try {
|
||||
adapter = profile.NetworkAdapter();
|
||||
} catch (...) {
|
||||
} catch (const winrt::hresult_error &ex) {
|
||||
qCWarning(lcNetInfoNLM) << "Failed to obtain network adapter:"
|
||||
<< QSystemError::windowsComString(ex.code());
|
||||
// pass, we will return Unknown anyway
|
||||
}
|
||||
if (adapter == nullptr)
|
||||
@ -231,7 +233,9 @@ QNetworkInformation::TransportMedium getTransportMedium(const ConnectionProfile
|
||||
ConnectionCost cost(nullptr);
|
||||
try {
|
||||
cost = profile.GetConnectionCost();
|
||||
} catch (...) {
|
||||
} catch (const winrt::hresult_error &ex) {
|
||||
qCWarning(lcNetInfoNLM) << "Failed to obtain connection cost:"
|
||||
<< QSystemError::windowsComString(ex.code());
|
||||
// pass, we return false if we get an empty object back anyway
|
||||
}
|
||||
if (cost == nullptr)
|
||||
@ -247,7 +251,9 @@ void QNetworkListManagerEvents::emitWinRTUpdates()
|
||||
ConnectionProfile profile = nullptr;
|
||||
try {
|
||||
profile = NetworkInformation::GetInternetConnectionProfile();
|
||||
} catch (...) {
|
||||
} catch (const winrt::hresult_error &ex) {
|
||||
qCWarning(lcNetInfoNLM) << "Failed to obtain connection profile:"
|
||||
<< QSystemError::windowsComString(ex.code());
|
||||
// pass, we would just return early if we get an empty object back anyway
|
||||
}
|
||||
if (profile == nullptr)
|
||||
|
Loading…
x
Reference in New Issue
Block a user