소스 검색

Catch exceptions when calling close in destructor

Paul-Louis Ageneau 3 년 전
부모
커밋
34423378ab
3개의 변경된 파일21개의 추가작업 그리고 3개의 파일을 삭제
  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),
       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(); }
 

+ 7 - 1
src/peerconnection.cpp

@@ -48,7 +48,13 @@ PeerConnection::PeerConnection() : PeerConnection(Configuration()) {}
 PeerConnection::PeerConnection(Configuration 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(); }
 

+ 7 - 1
src/websocket.cpp

@@ -36,7 +36,13 @@ WebSocket::WebSocket(impl_ptr<impl::WebSocket> impl)
     : CheshireCat<impl::WebSocket>(std::move(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; }