Skip to content

Commit

Permalink
Don't throw unhandled exception when closing sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamSimpson committed Jan 11, 2018
1 parent 5620c19 commit 2768150
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 6 additions & 3 deletions Builder/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,11 @@ int main(int argc, char *argv[]) {
Logger::error("Unknown exception caught!");
}

// Close connection
client_stream.close(websocket::close_code::normal);

// Attempt to close connection
try {
client_stream.close(websocket::close_code::normal);
} catch(...) {
Logger::error("Failed to cleanly close the WebSocket");
}
return 0;
}
10 changes: 7 additions & 3 deletions Client/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,13 @@ int main(int argc, char *argv[]) {
Logger::error("Unknown exception caught!");
}

// Disconnect from builder and queue
builder_stream.close(websocket::close_code::normal);
queue_stream.close(websocket::close_code::normal);
// Attempt to disconnect from builder and queue
try {
builder_stream.close(websocket::close_code::normal);
queue_stream.close(websocket::close_code::normal);
} catch(...) {
Logger::debug("Failed to cleanly close the WebSockets");
}

// Show the cursor
std::cout<<"\e[?25h";
Expand Down

0 comments on commit 2768150

Please sign in to comment.