Added code to deal with improperly formatted codes

master
Aadhavan Srinivasan 8 months ago
parent c8bc17fbce
commit 4378aa3c6a

@ -63,6 +63,9 @@ namespace connect_code {
/* Given a code, decode it and return a vector with the address and port */
std::vector<std::string> decode(std::string connect_code) {
if (connect_code.find("_") == std::string::npos) {
throw std::invalid_argument("Invalid code entered.");
}
std::vector<std::string> result = tokenize_str(connect_code, "_"); /* Split the string into address and port */
std::string address = result[0]; /* Address (in base 16) */
std::string port = result[1]; /* Port (in base 16) */
@ -80,5 +83,4 @@ namespace connect_code {
return ret_val;
}
}

Loading…
Cancel
Save