Browse Source

Catch exceptions when calling close in destructor

Paul-Louis Ageneau 3 years ago
parent
commit
34423378ab
3 changed files with 21 additions and 3 deletions
  1. 7 1
      src/datachannel.cpp
  2. 7 1
      src/peerconnection.cpp
  3. 7 1
      src/websocket.cpp

+ 7 - 1
src/datachannel.cpp

@@ -36,7 +36,13 @@ DataChannel::DataChannel(impl_ptr<impl::DataChannel> impl)
     : CheshireCat<impl::DataChannel>(impl),
     : CheshireCat<impl::DataChannel>(impl),
       Channel(std::dynamic_pointer_cast<impl::Channel>(impl)) {}
       Channel(std::dynamic_pointer_cast<impl::Channel>(impl)) {}
 
 
-DataChannel::~DataChannel() { close(); }
+DataChannel::~DataChannel() {
+	try {
+		close();
+	} catch (const std::exception &e) {
+		PLOG_ERROR << e.what();
+	}
+}
 
 
 void DataChannel::close() { return impl()->close(); }
 void DataChannel::close() { return impl()->close(); }
 
 

+ 7 - 1
src/peerconnection.cpp

@@ -48,7 +48,13 @@ PeerConnection::PeerConnection() : PeerConnection(Configuration()) {}
 PeerConnection::PeerConnection(Configuration config)
 PeerConnection::PeerConnection(Configuration config)
     : CheshireCat<impl::PeerConnection>(std::move(config)) {}
     : CheshireCat<impl::PeerConnection>(std::move(config)) {}
 
 
-PeerConnection::~PeerConnection() { close(); }
+PeerConnection::~PeerConnection() {
+	try {
+		close();
+	} catch (const std::exception &e) {
+		PLOG_ERROR << e.what();
+	}
+}
 
 
 void PeerConnection::close() { impl()->close(); }
 void PeerConnection::close() { impl()->close(); }
 
 

+ 7 - 1
src/websocket.cpp

@@ -36,7 +36,13 @@ WebSocket::WebSocket(impl_ptr<impl::WebSocket> impl)
     : CheshireCat<impl::WebSocket>(std::move(impl)),
     : CheshireCat<impl::WebSocket>(std::move(impl)),
       Channel(std::dynamic_pointer_cast<impl::Channel>(CheshireCat<impl::WebSocket>::impl())) {}
       Channel(std::dynamic_pointer_cast<impl::Channel>(CheshireCat<impl::WebSocket>::impl())) {}
 
 
-WebSocket::~WebSocket() { impl()->remoteClose(); }
+WebSocket::~WebSocket() {
+	try {
+		impl()->remoteClose();
+	} catch (const std::exception &e) {
+		PLOG_ERROR << e.what();
+	}
+}
 
 
 WebSocket::State WebSocket::readyState() const { return impl()->state; }
 WebSocket::State WebSocket::readyState() const { return impl()->state; }