diff --git a/includes/exception_consts.hpp b/includes/exception_consts.hpp index 078546c..f418e99 100644 --- a/includes/exception_consts.hpp +++ b/includes/exception_consts.hpp @@ -5,5 +5,6 @@ static const int EXCEPT_CONNREFUSED = 10; static const int EXCEPT_TOOFEWARGS = 15; static const int EXCEPT_INVALIDARGS = 20; static const int EXCEPT_ADDRNOTAVAIL = 25; +static const int EXCEPT_INVALIDIP = 30; #endif diff --git a/main.cpp b/main.cpp index aec6c30..72c947e 100644 --- a/main.cpp +++ b/main.cpp @@ -96,7 +96,7 @@ Mode check_server_client(int argc, char** argv, Server* server, Client* client) /* Check if IP is valid */ if (check_ip_ver(addr.data()) < 0) { - throw EXCEPT_INVALIDARGS; + throw EXCEPT_INVALIDIP; } std::string code = connect_code::encode(addr, std::to_string(port)); @@ -134,7 +134,7 @@ int main(int argc, char** argv) { return -1; } if (e == EXCEPT_INVALIDARGS) { - std::cout << "Invalid argument.." << std::endl; + std::cout << "Invalid argument." << std::endl; return -2; } if (e == EXCEPT_CONNREFUSED) { @@ -145,9 +145,13 @@ int main(int argc, char** argv) { std:: cout << "Unable to use requested address for server." << std::endl; return -4; } + if (e == EXCEPT_INVALIDIP) { + std::cout << "Invalid IP address provided." << std::endl; + return -5; + } } catch(std::invalid_argument& inv) { std::cout << inv.what() << std::endl; - return -5; + return -6; } /* Initialize window and other variables */