Skip to content

Commit

Permalink
Attempt to fix runtime crash
Browse files Browse the repository at this point in the history
  • Loading branch information
qwertychouskie committed Jul 1, 2024
1 parent 89f1c9d commit 2680cd0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/native/cpp/CANBridgeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,17 @@ int parse_serial_com_port(const std::string& in) {
if(!in.empty() && (substr_break < in.length())) {
std::string num = in.substr(substr_break, in.length());
if (!num.empty()) {
return std::stoi(num);
int returnval = -1;
try
{
returnval = std::stoi(num);
}
catch(const std::exception& e)
{
std::cerr << 'parse_serial_com_port: Error running stoi: ' << e.what() << '\n';
}

return returnval;
}
}

Expand Down

0 comments on commit 2680cd0

Please sign in to comment.