throw instead of exit
This commit is contained in:
parent
99ecd586d4
commit
91fce00df3
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue