From 06eebda835e00582e70890890aad08beaf63db05 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 6 Feb 2024 11:33:12 +0100 Subject: Don't give confusing errors about WEBVTT when there are errors in a Subrip file (#2733). --- src/lib/string_text_file.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/lib/string_text_file.cc') diff --git a/src/lib/string_text_file.cc b/src/lib/string_text_file.cc index 348ccd1d5..9b43b35a6 100644 --- a/src/lib/string_text_file.cc +++ b/src/lib/string_text_file.cc @@ -25,6 +25,7 @@ #include "string_text_file_content.h" #include #include +#include #include #include #include @@ -105,9 +106,14 @@ StringTextFile::StringTextFile (shared_ptr content) if (ext == ".srt") { try { reader.reset(new sub::SubripReader(utf8.get())); - } catch (...) { - /* Sometimes files are have the .srt extension but are really WEBVTT */ - reader.reset(new sub::WebVTTReader(utf8.get())); + } catch (sub::SubripError& subrip_error) { + /* Sometimes files are have the .srt extension but are really WEBVTT... */ + try { + reader.reset(new sub::WebVTTReader(utf8.get())); + } catch (sub::WebVTTHeaderError&) { + /* ...but in this case there isn't even a WebVTT error */ + throw subrip_error; + } } } else if (ext == ".ssa" || ext == ".ass") { reader.reset(new sub::SSAReader(utf8.get())); -- cgit v1.2.3