throw instead of exit

This commit is contained in:
VaclavT 2021-05-03 18:33:46 +02:00
parent 99ecd586d4
commit 91fce00df3
1 changed files with 1 additions and 2 deletions

View File

@ -114,8 +114,7 @@ HttpClient::doGetRequest(const std::string &url, const std::unordered_map<std::s
std::string HttpClient::inetAddress(std::string hostname) { std::string HttpClient::inetAddress(std::string hostname) {
hostent *record = gethostbyname(hostname.c_str()); hostent *record = gethostbyname(hostname.c_str());
if (record == NULL) { if (record == NULL) {
std::cerr << hostname << " is unavailable" << std::endl; throw std::runtime_error(hostname + " network unavailable.");
exit(1);
} }
in_addr *address = (in_addr *) record->h_addr; in_addr *address = (in_addr *) record->h_addr;
std::string ip_address = inet_ntoa(*address); std::string ip_address = inet_ntoa(*address);