Sfoglia il codice sorgente

network: don't use assert to check if no network interfaces are returned

Sönke Holz 5 anni fa
parent
commit
b18e1d031f
1 ha cambiato i file con 4 aggiunte e 2 eliminazioni
  1. 4 2
      src/core/network/network.cpp

+ 4 - 2
src/core/network/network.cpp

@@ -363,8 +363,10 @@ NetworkInstance::~NetworkInstance() {
 std::optional<IPv4Address> GetHostIPv4Address() {
 std::optional<IPv4Address> GetHostIPv4Address() {
     const std::string& selected_network_interface = Settings::values.network_interface.GetValue();
     const std::string& selected_network_interface = Settings::values.network_interface.GetValue();
     const auto network_interfaces = Network::GetAvailableNetworkInterfaces();
     const auto network_interfaces = Network::GetAvailableNetworkInterfaces();
-    ASSERT_MSG(network_interfaces.size() > 0,
-               "GetAvailableNetworkInterfaces returned no interfaces");
+    if (network_interfaces.size() == 0) {
+        LOG_ERROR(Network, "GetAvailableNetworkInterfaces returned no interfaces");
+        return {};
+    }
 
 
     const auto res = std::ranges::find_if(network_interfaces,
     const auto res = std::ranges::find_if(network_interfaces,
                                           [&selected_network_interface](const auto& interface) {
                                           [&selected_network_interface](const auto& interface) {