Fix some build warnings on macOS.
[libsub.git] / src / exceptions.h
index c6f7f1a668d3af6a76c1b39003713c33a86cd262..e0d0e90a9a2d6c7a4207bb1e732e9b0415dbe229 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 #ifndef LIBSUB_EXCEPTIONS_H
 #define LIBSUB_EXCEPTIONS_H
 
+#include <list>
 #include <stdexcept>
 #include <string>
+#include <vector>
 
 namespace sub {
 
@@ -53,35 +55,74 @@ public:
 class SubripError : public std::runtime_error
 {
 public:
-       SubripError (std::string saw, std::string expecting)
-               : std::runtime_error ("Error in SubRip file: saw " + saw + " while expecting " + expecting)
+       SubripError (std::string saw, std::string expecting, std::list<std::string> context);
+       ~SubripError () throw () {}
+
+       std::list<std::string> context () const {
+               return _context;
+       }
+
+private:
+       std::list<std::string> _context;
+};
+
+
+/** @class WebVTTError
+ *  @brief An error raised when reading a WebVTT file.
+ */
+class WebVTTError : public std::runtime_error
+{
+public:
+       WebVTTError(std::string message)
+               : std::runtime_error(message.c_str())
        {}
+
+       WebVTTError(std::string saw, std::string expecting, std::list<std::string> context);
+
+       ~WebVTTError() throw () {}
+
+       std::list<std::string> context() const {
+               return _context;
+       }
+
+private:
+       std::list<std::string> _context;
 };
 
-class MXFError : public std::runtime_error
+
+class WebVTTHeaderError : public WebVTTError
 {
 public:
-       MXFError (std::string const & message)
-               : std::runtime_error (message)
+       WebVTTHeaderError()
+               : WebVTTError("No WEBVTT header found")
        {}
 };
 
-class UnknownFrameRateError : public std::runtime_error
+
+class SSAError : public std::runtime_error
 {
 public:
-       UnknownFrameRateError ()
-               : std::runtime_error ("unknown frame rate")
+       SSAError (std::string message)
+               : std::runtime_error(message)
        {}
 };
 
-class DCPError : public std::runtime_error
+class MXFError : public std::runtime_error
 {
 public:
-       DCPError (std::string const & message)
+       MXFError (std::string const & message)
                : std::runtime_error (message)
        {}
 };
 
+class UnknownFrameRateError : public std::runtime_error
+{
+public:
+       UnknownFrameRateError ()
+               : std::runtime_error ("unknown frame rate")
+       {}
+};
+
 class ProgrammingError : public std::runtime_error
 {
 public: