Commit 3a6f6606 by 王成 Committed by GitHub

新增Assert异常类型,解决国标重复推流不注销问题 (#2393)

Co-authored-by: wangcheng <wangcheng@xwmail.com>
Co-authored-by: xia-chu <771730766@qq.com>
parent 24eaaf68
...@@ -26,7 +26,7 @@ void Assert_Throw(int failed, const char *exp, const char *func, const char *fil ...@@ -26,7 +26,7 @@ void Assert_Throw(int failed, const char *exp, const char *func, const char *fil
printer << ", " << str; printer << ", " << str;
} }
printer << "), function " << func << ", file " << file << ", line " << line << "."; printer << "), function " << func << ", file " << file << ", line " << line << ".";
throw std::runtime_error(printer); throw mediakit::AssertFailedException(printer);
} }
} }
} }
......
...@@ -80,6 +80,13 @@ extern void Assert_Throw(int failed, const char *exp, const char *func, const ch ...@@ -80,6 +80,13 @@ extern void Assert_Throw(int failed, const char *exp, const char *func, const ch
namespace mediakit { namespace mediakit {
class AssertFailedException : public std::runtime_error {
public:
template<typename ...T>
AssertFailedException(T && ...args) : std::runtime_error(std::forward<T>(args)...) {}
~AssertFailedException() override = default;
};
extern const char kServerName[]; extern const char kServerName[];
template <typename... ARGS> template <typename... ARGS>
......
...@@ -63,7 +63,7 @@ const char *PSDecoder::onSearchPacketTail(const char *data, size_t len) { ...@@ -63,7 +63,7 @@ const char *PSDecoder::onSearchPacketTail(const char *data, size_t len) {
//解析失败,丢弃所有数据 //解析失败,丢弃所有数据
return data + len; return data + len;
} catch (std::exception &ex) { } catch (AssertFailedException &ex) {
InfoL << "解析 ps 异常: bytes=" << len InfoL << "解析 ps 异常: bytes=" << len
<< ", exception=" << ex.what() << ", exception=" << ex.what()
<< ", hex=" << hexdump(data, MIN(len, 32)); << ", hex=" << hexdump(data, MIN(len, 32));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论