Skip to content

Commit 58f925d

Browse files
Copilottsaubergine
andauthored
Fix exception handling in chat.cpp: catch by const ref, handle out_of_range
Agent-Logs-Url: https://github.com/GobySoft/goby3-examples/sessions/5fba8fc7-e76b-45cb-9282-8ecf3b6dd51b Co-authored-by: tsaubergine <732276+tsaubergine@users.noreply.github.com>
1 parent 791016e commit 58f925d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎src/components/acomms/chat/chat.cpp‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@ int main(int argc, char* argv[])
7979
my_id_ = std::stoi(argv[2]);
8080
buddy_id_ = std::stoi(argv[3]);
8181
}
82-
catch (std::invalid_argument&)
82+
catch (const std::invalid_argument&)
83+
{
84+
std::cerr << "bad value for my_id: " << argv[2] << " or buddy_id: " << argv[3]
85+
<< ". these must be unsigned integers." << std::endl;
86+
return startup_failure();
87+
}
88+
catch (const std::out_of_range&)
8389
{
8490
std::cerr << "bad value for my_id: " << argv[2] << " or buddy_id: " << argv[3]
8591
<< ". these must be unsigned integers." << std::endl;

0 commit comments

Comments
 (0)