From: Carl Hetherington Date: Tue, 6 Feb 2024 10:32:26 +0000 (+0100) Subject: Throw a specific exception when no WEBVTT header is found. X-Git-Tag: v1.6.47 X-Git-Url: https://main.carlh.net/gitweb/?p=libsub.git;a=commitdiff_plain Throw a specific exception when no WEBVTT header is found. --- diff --git a/src/exceptions.h b/src/exceptions.h index 1895f11..e0d0e90 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -90,6 +90,15 @@ private: }; +class WebVTTHeaderError : public WebVTTError +{ +public: + WebVTTHeaderError() + : WebVTTError("No WEBVTT header found") + {} +}; + + class SSAError : public std::runtime_error { public: diff --git a/src/web_vtt_reader.cc b/src/web_vtt_reader.cc index cd6844d..4618466 100644 --- a/src/web_vtt_reader.cc +++ b/src/web_vtt_reader.cc @@ -86,7 +86,7 @@ WebVTTReader::read(std::function ()> get_line) switch (state) { case State::HEADER: if (!boost::starts_with(*line, "WEBVTT")) { - throw WebVTTError("No WEBVTT header found"); + throw WebVTTHeaderError(); } state = State::DATA; break;