Fix missing words in properties windows (#874).
[dcpomatic.git] / src / lib / exceptions.h
index 06177863ab27e5720125c91b0320827c627251b7..3e7289a50e13e00c4c04259ff7c63bb65ba5bdce 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2014 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
 
 */
 
-/** @file  src/exceptions.h
+/** @file  src/lib/exceptions.h
  *  @brief Our exceptions.
  */
 
+#ifndef DCPOMATIC_EXCEPTIONS_H
+#define DCPOMATIC_EXCEPTIONS_H
+
+extern "C" {
+#include <libavutil/pixfmt.h>
+}
+#include <boost/filesystem.hpp>
 #include <stdexcept>
-#include <sstream>
 #include <cstring>
 
-/** @class StringError
- *  @brief A parent class for exceptions using messages held in a std::string
- */
-class StringError : public std::exception
-{
-public:
-       /** @param w Error message */
-       StringError (std::string w) {
-               _what = w;
-       }
-
-       virtual ~StringError () throw () {}
-
-       /** @return error message */
-       char const * what () const throw () {
-               return _what.c_str ();
-       }
-
-protected:
-       /** error message */
-       std::string _what;
-};
-
 /** @class DecodeError
  *  @brief A low-level problem with the decoder (possibly due to the nature
  *  of a source file).
  */
-class DecodeError : public StringError
+class DecodeError : public std::runtime_error
 {
 public:
        DecodeError (std::string s)
-               : StringError (s)
+               : std::runtime_error (s)
        {}
 };
 
 /** @class EncodeError
  *  @brief A low-level problem with an encoder.
  */
-class EncodeError : public StringError
+class EncodeError : public std::runtime_error
 {
 public:
        EncodeError (std::string s)
-               : StringError (s)
+               : std::runtime_error (s)
        {}
 };
 
 /** @class FileError.
  *  @brief Parent class for file-related errors.
  */
-class FileError : public StringError
+class FileError : public std::runtime_error
 {
 public:
        /** @param m Error message.
         *  @param f Name of the file that this exception concerns.
         */
-       FileError (std::string m, std::string f)
-               : StringError (m)
+       FileError (std::string m, boost::filesystem::path f)
+               : std::runtime_error (m)
                , _file (f)
        {}
 
        virtual ~FileError () throw () {}
 
        /** @return name of the file that this exception concerns */
-       std::string file () const {
+       boost::filesystem::path file () const {
                return _file;
        }
 
 private:
        /** name of the file that this exception concerns */
-       std::string _file;
+       boost::filesystem::path _file;
+};
+
+class JoinError : public std::runtime_error
+{
+public:
+       JoinError (std::string s)
+               : std::runtime_error (s)
+       {}
 };
-       
 
 /** @class OpenFileError.
  *  @brief Indicates that some error occurred when trying to open a file.
@@ -105,9 +95,7 @@ class OpenFileError : public FileError
 {
 public:
        /** @param f File that we were trying to open */
-       OpenFileError (std::string f)
-               : FileError ("could not open file " + f, f)
-       {}
+       OpenFileError (boost::filesystem::path f);
 };
 
 /** @class CreateFileError.
@@ -117,9 +105,7 @@ class CreateFileError : public FileError
 {
 public:
        /** @param f File that we were trying to create */
-       CreateFileError (std::string f)
-               : FileError ("could not create file " + f, f)
-       {}
+       CreateFileError (boost::filesystem::path f);
 };
 
 
@@ -132,16 +118,7 @@ public:
        /** @param f File that we were trying to read from.
         *  @param e errno value, or 0.
         */
-       ReadFileError (std::string f, int e = 0)
-               : FileError ("", f)
-       {
-               std::stringstream s;
-               s << "could not read from file " << f;
-               if (e) {
-                       s << " (" << strerror (e) << ")";
-               }
-               _what = s.str ();
-       }
+       ReadFileError (boost::filesystem::path f, int e = 0);
 };
 
 /** @class WriteFileError.
@@ -153,29 +130,20 @@ public:
        /** @param f File that we were trying to write to.
         *  @param e errno value, or 0.
         */
-       WriteFileError (std::string f, int e)
-               : FileError ("", f)
-       {
-               std::stringstream s;
-               s << "could not write to file " << f;
-               if (e) {
-                       s << " (" << strerror (e) << ")";
-               }
-               _what = s.str ();
-       }
+       WriteFileError (boost::filesystem::path f, int e);
 };
 
 /** @class SettingError.
  *  @brief Indicates that something is wrong with a setting.
  */
-class SettingError : public StringError
+class SettingError : public std::runtime_error
 {
 public:
        /** @param s Name of setting that was required.
         *  @param m Message.
         */
        SettingError (std::string s, std::string m)
-               : StringError (m)
+               : std::runtime_error (m)
                , _setting (s)
        {}
 
@@ -197,9 +165,7 @@ class MissingSettingError : public SettingError
 {
 public:
        /** @param s Name of setting that was required */
-       MissingSettingError (std::string s)
-               : SettingError (s, "missing required setting " + s)
-       {}
+       MissingSettingError (std::string s);
 };
 
 /** @class BadSettingError
@@ -214,21 +180,72 @@ public:
        {}
 };
 
-/** @class NetworkError.
+/** @class NetworkError
  *  @brief Indicates some problem with communication on the network.
  */
-class NetworkError : public StringError
+class NetworkError : public std::runtime_error
 {
 public:
        NetworkError (std::string s)
-               : StringError (s)
+               : std::runtime_error (s)
        {}
 };
 
-class KDMError : public StringError
+/** @class KDMError
+ *  @brief A problem with a KDM.
+ */
+class KDMError : public std::runtime_error
 {
 public:
        KDMError (std::string s)
-               : StringError (s)
+               : std::runtime_error (s)
        {}
 };
+
+/** @class PixelFormatError
+ *  @brief A problem with an unsupported pixel format.
+ */
+class PixelFormatError : public std::runtime_error
+{
+public:
+       PixelFormatError (std::string o, AVPixelFormat f);
+};
+
+/** @class TextSubtitleError
+ *  @brief An error that occurs while parsing a TextSubtitleError file.
+ */
+class TextSubtitleError : public FileError
+{
+public:
+       TextSubtitleError (std::string, std::string, boost::filesystem::path);
+};
+
+class DCPError : public std::runtime_error
+{
+public:
+       DCPError (std::string s)
+               : std::runtime_error (s)
+       {}
+};
+
+class InvalidSignerError : public std::runtime_error
+{
+public:
+       InvalidSignerError ();
+};
+
+class ProgrammingError : public std::runtime_error
+{
+public:
+       ProgrammingError (std::string file, int line);
+};
+
+class TextEncodingError : public std::runtime_error
+{
+public:
+       TextEncodingError (std::string s)
+               : std::runtime_error (s)
+       {}
+};
+
+#endif