summaryrefslogtreecommitdiff
path: root/src/subrip_reader.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-03-15 16:27:50 +0000
committerCarl Hetherington <cth@carlh.net>2019-03-15 16:40:21 +0000
commitc57b95b53ed6508516007e0fc7f7b4058f7a6748 (patch)
treec0e424280c1dad6f153bd95492c1b1006d892a1d /src/subrip_reader.cc
parent88fddc7012ecb3443b7ad16ebdd9134029c29e86 (diff)
Give better errors on malformed subrip times.v1.4.4
Diffstat (limited to 'src/subrip_reader.cc')
-rw-r--r--src/subrip_reader.cc33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/subrip_reader.cc b/src/subrip_reader.cc
index 5625679..b547db0 100644
--- a/src/subrip_reader.cc
+++ b/src/subrip_reader.cc
@@ -160,12 +160,33 @@ SubripReader::convert_time (string t)
throw SubripError (t, "time in the format h:m:s,ms", _context);
}
- return Time::from_hms (
- lexical_cast<int> (a[0]),
- lexical_cast<int> (a[1]),
- lexical_cast<int> (b[0]),
- lexical_cast<int> (b[1])
- );
+ int h, m, s, ms;
+
+ try {
+ h = lexical_cast<int>(a[0]);
+ } catch (boost::bad_lexical_cast &) {
+ throw SubripError (t, "integer hour value", _context);
+ }
+
+ try {
+ m = lexical_cast<int>(a[1]);
+ } catch (boost::bad_lexical_cast &) {
+ throw SubripError (t, "integer minute value", _context);
+ }
+
+ try {
+ s = lexical_cast<int>(b[0]);
+ } catch (boost::bad_lexical_cast &) {
+ throw SubripError (t, "integer second value", _context);
+ }
+
+ try {
+ ms = lexical_cast<int>(b[1]);
+ } catch (boost::bad_lexical_cast &) {
+ throw SubripError (t, "integer millisecond value", _context);
+ }
+
+ return Time::from_hms (h, m, s, ms);
}
void