From 14740e4a64e7e0453b7c5e4b3d604f08c4929222 Mon Sep 17 00:00:00 2001 From: Tijmen van Nesselrooij Date: Sun, 16 Jun 2019 11:13:21 +0200 Subject: [PATCH] Catch runtime error writing to socket --- src/server/connectionoperator.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/server/connectionoperator.cpp b/src/server/connectionoperator.cpp index 0431175..25433bf 100644 --- a/src/server/connectionoperator.cpp +++ b/src/server/connectionoperator.cpp @@ -9,7 +9,14 @@ void ConnectionOperator::SendResponse(Connection const & connection, Http::Response const & response) const { auto bytesToSend = response.Serialize(); - connection.WriteBytes(bytesToSend); + try + { + connection.WriteBytes(bytesToSend); + } + catch(std::runtime_error & e) + { + Logger::GetInstance().Error("Error writing data to connection"); + } } void ConnectionOperator::HandleNewConnection(Connection const & newConnection)