diff --git a/modules/YetiDriver/yeti_comms/firmware_version.hpp b/modules/YetiDriver/yeti_comms/firmware_version.hpp index c818faa1c..8bc0f4d7b 100644 --- a/modules/YetiDriver/yeti_comms/firmware_version.hpp +++ b/modules/YetiDriver/yeti_comms/firmware_version.hpp @@ -56,15 +56,30 @@ class YetiFirmwareVersion { // parse into major, minor and revision if (tokens.size() >= 1) { - major = std::stoi(tokens[0]); + try { + major = std::stoi(tokens[0]); + } catch (...) { + // Set to 0 if we cannot parse it + major = 0; + } } if (tokens.size() >= 2) { - minor = std::stoi(tokens[1]); + try { + minor = std::stoi(tokens[1]); + } catch (...) { + // Set to 0 if we cannot parse it + minor = 0; + } } if (tokens.size() >= 3) { - revision = std::stoi(tokens[2]); + try { + revision = std::stoi(tokens[2]); + } catch (...) { + // Set to 0 if we cannot parse it + revision = 0; + } } }