Throw exception instead of returning error code from send function.
Change-Id: I87d2805dfb7f8757c0366600d8937023edddf54a
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/message_handler.cpp b/message_handler.cpp
index ef9eb06..e66e39c 100644
--- a/message_handler.cpp
+++ b/message_handler.cpp
@@ -163,7 +163,7 @@
return command;
}
-int Handler::send(Message& outMessage)
+void Handler::send(Message& outMessage)
{
auto session = (std::get<session::Manager&>(singletonPool).getSession(
sessionID)).lock();
@@ -171,15 +171,12 @@
// Flatten the packet
auto packet = parser::flatten(outMessage, sessionHeader, *session);
- // Read the packet
+ // Write the packet
auto writeStatus = channel->write(packet);
if (writeStatus < 0)
{
- std::cerr << "E> Error in writing : " << std::hex << writeStatus
- << "\n";
+ throw std::runtime_error("Error in writing to socket");
}
-
- return writeStatus;
}
void Handler::setChannelInSession() const