throw instead of exit

This commit is contained in:
2021-05-03 18:33:46 +02:00
parent 99ecd586d4
commit 91fce00df3

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) {
hostent *record = gethostbyname(hostname.c_str());
if (record == NULL) {
std::cerr << hostname << " is unavailable" << std::endl;
exit(1);
throw std::runtime_error(hostname + " network unavailable.");
}
in_addr *address = (in_addr *) record->h_addr;
std::string ip_address = inet_ntoa(*address);