face: handle exceptions in WebSocket sending path

Change-Id: I231f201d0999f74369fab5ff98b24b2185e45815
Refs: #1732
diff --git a/daemon/face/websocket-face.cpp b/daemon/face/websocket-face.cpp
index 9e56bb5..c0d6732 100644
--- a/daemon/face/websocket-face.cpp
+++ b/daemon/face/websocket-face.cpp
@@ -43,17 +43,39 @@
 void
 WebSocketFace::sendInterest(const Interest& interest)
 {
+  if (m_closed)
+    return;
+
   this->onSendInterest(interest);
   const Block& payload = interest.wireEncode();
-  m_server.send(m_handle, payload.wire(), payload.size(), websocketpp::frame::opcode::binary);
+
+  try {
+    m_server.send(m_handle, payload.wire(), payload.size(),
+                  websocketpp::frame::opcode::binary);
+  }
+  catch (const websocketpp::lib::error_code& e) {
+    NFD_LOG_DEBUG("Failed to send Interest because: " << e
+                  << "(" << e.message() << ")");
+  }
 }
 
 void
 WebSocketFace::sendData(const Data& data)
 {
+  if (m_closed)
+    return;
+
   this->onSendData(data);
   const Block& payload = data.wireEncode();
-  m_server.send(m_handle, payload.wire(), payload.size(), websocketpp::frame::opcode::binary);
+
+  try {
+    m_server.send(m_handle, payload.wire(), payload.size(),
+                  websocketpp::frame::opcode::binary);
+  }
+  catch (const websocketpp::lib::error_code& e) {
+    NFD_LOG_DEBUG("Failed to send Data because: " << e
+                  << "(" << e.message() << ")");
+  }
 }
 
 void