Fix some unused variable warnings.
[libsub.git] / src / exceptions.h
index 5e784ee9d28ae2d2c313c2c7766f0c78e5733de8..2bb7018886bd972ef4c72151c42590eb87f41621 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2016 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 <stdexcept>
 #include <string>
+#include <list>
 
 namespace sub {
 
-class XMLError : public std::exception
+/** @class XMLError
+ *  @brief An error raised when reading an XML file.
+ */
+class XMLError : public std::runtime_error
+{
+public:
+       XMLError (std::string const & message)
+               : std::runtime_error (message)
+       {}
+};
+
+/** @class STLError
+ *  @brief An error raised when reading a binary STL file.
+ */
+class STLError : public std::runtime_error
+{
+public:
+       STLError (std::string const & message)
+               : std::runtime_error (message)
+       {}
+};
+
+/** @class SubripError
+ *  @brief An error raised when reading a Subrip file.
+ */
+class SubripError : public std::runtime_error
 {
 public:
-       XMLError (std::string const & message) : _message (message) {}
-       ~XMLError () throw () {}
+       SubripError (std::string saw, std::string expecting, std::list<std::string> context);
+       ~SubripError () throw () {}
 
-       /** @return error message */
-       char const * what () const throw () {
-               return _message.c_str ();
+       std::list<std::string> context () const {
+               return _context;
        }
 
 private:
-       /** error message */
-       std::string _message;
+       std::list<std::string> _context;
 };
-       
-class STLError : public std::exception
+
+class SSAError : public std::runtime_error
 {
 public:
-       STLError (std::string const & message) : _message (message) {}
-       ~STLError () throw () {}
+       SSAError (std::string message)
+               : std::runtime_error(message)
+       {}
+};
 
-       /** @return error message */
-       char const * what () const throw () {
-               return _message.c_str ();
-       }
+class MXFError : public std::runtime_error
+{
+public:
+       MXFError (std::string const & message)
+               : std::runtime_error (message)
+       {}
+};
 
-private:
-       /** error message */
-       std::string _message;
+class UnknownFrameRateError : public std::runtime_error
+{
+public:
+       UnknownFrameRateError ()
+               : std::runtime_error ("unknown frame rate")
+       {}
+};
+
+class DCPError : public std::runtime_error
+{
+public:
+       DCPError (std::string const & message)
+               : std::runtime_error (message)
+       {}
+};
+
+class ProgrammingError : public std::runtime_error
+{
+public:
+       ProgrammingError (std::string file, int line);
 };
 
 }
+
+#endif