Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64e597a6 authored by Josh Gao's avatar Josh Gao
Browse files

adb: improve network_connect error messages.

Test: manual
Change-Id: If8747ba1951d3c87561fbd3fb4968821243b2ee2
parent eb0875db
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <string>

#include <android-base/logging.h>
#include <android-base/stringprintf.h>
#include <cutils/sockets.h>

#include "adb_unique_fd.h"
@@ -136,11 +137,13 @@ int network_connect(const std::string& host, int port, int type, int timeout, st
        return fd;
    }
    if (getaddrinfo_error != 0) {
        *error = gai_strerror(getaddrinfo_error);
        LOG(WARNING) << "failed to resolve host '" << host << "': " << *error;
        *error = android::base::StringPrintf("failed to resolve host: '%s': %s", host.c_str(),
                                             gai_strerror(getaddrinfo_error));
        LOG(WARNING) << *error;
    } else {
        *error = strerror(errno);
        LOG(WARNING) << "failed to connect to '" << host << "': " << *error;
        *error = android::base::StringPrintf("failed to connect to '%s:%d': %s", host.c_str(), port,
                                             strerror(errno));
        LOG(WARNING) << *error;
    }
    return -1;
}