Give a better error when opening a DCP with File -> Open by mistake (#1723).
[dcpomatic.git] / src / lib / exceptions.h
index ddd1e36035f9dfb6a5e71827a2b47f8c978da3f0..73b8cc85a7876259c594f5d1fee92acd9cd85897 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -25,6 +25,7 @@
 #ifndef DCPOMATIC_EXCEPTIONS_H
 #define DCPOMATIC_EXCEPTIONS_H
 
+#include "compose.hpp"
 extern "C" {
 #include <libavutil/pixfmt.h>
 }
@@ -73,7 +74,7 @@ public:
         *  @param f Name of the file that this exception concerns.
         */
        FileError (std::string m, boost::filesystem::path f)
-               : std::runtime_error (m)
+               : std::runtime_error (String::compose("%1 with %2", m, f.string()))
                , _file (f)
        {}
 
@@ -116,6 +117,22 @@ public:
        OpenFileError (boost::filesystem::path f, int error, Mode mode);
 };
 
+class FileNotFoundError : public std::runtime_error
+{
+public:
+       FileNotFoundError (boost::filesystem::path f);
+       virtual ~FileNotFoundError () throw () {}
+
+       /** @return name of the file that this exception concerns */
+       boost::filesystem::path file () const {
+               return _file;
+       }
+
+private:
+       /** name of the file that this exception concerns */
+       boost::filesystem::path _file;
+};
+
 /** @class ReadFileError.
  *  @brief Indicates that some error occurred when trying to read from a file
  */