summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/exceptions.cc7
-rw-r--r--src/lib/exceptions.h16
-rw-r--r--src/lib/film.cc4
3 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/exceptions.cc b/src/lib/exceptions.cc
index bf474e3ea..4b518e73a 100644
--- a/src/lib/exceptions.cc
+++ b/src/lib/exceptions.cc
@@ -40,6 +40,13 @@ OpenFileError::OpenFileError (boost::filesystem::path f, int error, Mode mode)
}
+FileNotFoundError::FileNotFoundError (boost::filesystem::path f)
+ : runtime_error(String::compose("File %1 not found", f.string()))
+ , _file (f)
+{
+
+}
+
ReadFileError::ReadFileError (boost::filesystem::path f, int e)
: FileError (String::compose (_("could not read from file %1 (%2)"), f.string(), strerror (e)), f)
{
diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h
index 99f0a5d87..bd94fb92b 100644
--- a/src/lib/exceptions.h
+++ b/src/lib/exceptions.h
@@ -117,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
*/
diff --git a/src/lib/film.cc b/src/lib/film.cc
index ede367ded..70142dcf3 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -454,6 +454,10 @@ Film::read_metadata (optional<boost::filesystem::path> path)
path = file (metadata_file);
}
+ if (!boost::filesystem::exists(*path)) {
+ throw FileNotFoundError(*path);
+ }
+
cxml::Document f ("Metadata");
f.read_file (path.get ());