dcp_trim -> trim
[dcpomatic.git] / src / lib / exceptions.h
index b16275c20696482ffb0d322b432372d8de15b39e..bf8e85f0bdfb7d939f76b90ad41c4571361bd874 100644 (file)
@@ -77,6 +77,9 @@ public:
 class FileError : public StringError
 {
 public:
+       /** @param m Error message.
+        *  @param f Name of the file that this exception concerns.
+        */
        FileError (std::string m, std::string f)
                : StringError (m)
                , _file (f)
@@ -84,11 +87,13 @@ public:
 
        virtual ~FileError () throw () {}
 
+       /** @return name of the file that this exception concerns */
        std::string file () const {
                return _file;
        }
 
 private:
+       /** name of the file that this exception concerns */
        std::string _file;
 };
        
@@ -117,6 +122,28 @@ public:
        {}
 };
 
+
+/** @class ReadFileError.
+ *  @brief Indicates that some error occurred when trying to read from a file
+ */
+class ReadFileError : public FileError
+{
+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 ();
+       }
+};
+
 /** @class WriteFileError.
  *  @brief Indicates that some error occurred when trying to write to a file
  */
@@ -197,19 +224,3 @@ public:
                : StringError (s)
        {}
 };
-
-class PlayError : public StringError
-{
-public:
-       PlayError (std::string s)
-               : StringError (s)
-       {}
-};
-
-class DVDError : public StringError
-{
-public:
-       DVDError (std::string s)
-               : StringError (s)
-       {}
-};