summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Belyavsky <[email protected]>2023-04-15 12:24:41 +0300
committerMårten Nordheim <[email protected]>2023-04-18 11:39:20 +0000
commitf6908c4f714f629bfe74babc731b6bbe0448ef2d (patch)
treeaba172afbe24fd553edf1805d57746b6ba6b90f7
parentca978e2c123aee991ee584cdd58edb338c25440b (diff)
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 <[email protected]>
-rw-r--r--src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.cpp b/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.cpp
index eb6b6888aff..7d6fd6d5c13 100644
--- a/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.cpp
+++ b/src/plugins/networkinformation/networklistmanager/qnetworklistmanagerevents.cpp
@@ -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)