From 99fca9ad1c84c67e0d7ecf652523bcfa7f455a2c Mon Sep 17 00:00:00 2001 From: Paul-Louis Ageneau Date: Tue, 1 Oct 2024 10:09:17 +0200 Subject: [PATCH] Reword send exceptions for clarity --- src/impl/datachannel.cpp | 5 ++++- src/impl/track.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/impl/datachannel.cpp b/src/impl/datachannel.cpp index 044952280..e724b324b 100644 --- a/src/impl/datachannel.cpp +++ b/src/impl/datachannel.cpp @@ -185,9 +185,12 @@ bool DataChannel::outgoing(message_ptr message) { std::shared_lock lock(mMutex); transport = mSctpTransport.lock(); - if (!transport || mIsClosed) + if (mIsClosed) throw std::runtime_error("DataChannel is closed"); + if (!transport) + throw std::runtime_error("DataChannel not open"); + if (!mStream.has_value()) throw std::logic_error("DataChannel has no stream assigned"); diff --git a/src/impl/track.cpp b/src/impl/track.cpp index 588045755..8bbbe778a 100644 --- a/src/impl/track.cpp +++ b/src/impl/track.cpp @@ -202,7 +202,7 @@ bool Track::transportSend([[maybe_unused]] message_ptr message) { std::shared_lock lock(mMutex); transport = mDtlsSrtpTransport.lock(); if (!transport) - throw std::runtime_error("Track is closed"); + throw std::runtime_error("Track is not open"); // Set recommended medium-priority DSCP value // See https://www.rfc-editor.org/rfc/rfc8837.html#section-5