summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dcp.cc12
-rw-r--r--src/dcp.h5
-rw-r--r--src/exceptions.cc22
-rw-r--r--src/exceptions.h22
4 files changed, 52 insertions, 9 deletions
diff --git a/src/dcp.cc b/src/dcp.cc
index c0d148c5..dc0ffeaa 100644
--- a/src/dcp.cc
+++ b/src/dcp.cc
@@ -69,17 +69,19 @@ DCP::DCP (boost::filesystem::path directory)
}
template<class T> void
-survivable_error (bool keep_going, list<string>* errors, T const & e)
+survivable_error (bool keep_going, list<shared_ptr<DCPReadError> >* errors, T const & e)
{
- if (keep_going && errors) {
- errors->push_back (e.what ());
+ if (keep_going) {
+ if (errors) {
+ errors->push_back (shared_ptr<T> (new T (e)));
+ }
} else {
throw e;
}
}
void
-DCP::read (bool keep_going, list<string>* errors)
+DCP::read (bool keep_going, list<shared_ptr<DCPReadError> >* errors)
{
/* Read the ASSETMAP */
@@ -112,7 +114,7 @@ DCP::read (bool keep_going, list<string>* errors)
boost::filesystem::path path = _directory / i->second;
if (!boost::filesystem::exists (path)) {
- survivable_error (keep_going, errors, FileError ("file not found", path, -1));
+ survivable_error (keep_going, errors, MissingAssetError (path));
continue;
}
diff --git a/src/dcp.h b/src/dcp.h
index 48b2df3c..66486ca0 100644
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -48,6 +48,7 @@ class XMLMetadata;
class Signer;
class DecryptedKDM;
class Asset;
+class DCPReadError;
namespace parse {
class AssetMap;
@@ -70,9 +71,9 @@ public:
/** Read the DCP's structure into this object.
* @param keep_going true to try to keep going in the face of (some) errors.
- * @param notes List of errors that will be added to if keep_going is true.
+ * @param errors List of errors that will be added to if keep_going is true.
*/
- void read (bool keep_going = false, std::list<std::string>* errors = 0);
+ void read (bool keep_going = false, std::list<boost::shared_ptr<DCPReadError> >* errors = 0);
/** Compare this DCP with another, according to various options.
* @param other DCP to compare this one to.
diff --git a/src/exceptions.cc b/src/exceptions.cc
index 48da4fcd..28846e16 100644
--- a/src/exceptions.cc
+++ b/src/exceptions.cc
@@ -47,4 +47,24 @@ TimeFormatError::TimeFormatError (string bad_time)
}
-
+MissingAssetError::MissingAssetError (boost::filesystem::path path, AssetType type)
+ : _path (path)
+ , _type (type)
+{
+ string type_name;
+ switch (_type) {
+ case MAIN_PICTURE:
+ type_name = " for main picture";
+ break;
+ case MAIN_SOUND:
+ type_name = " for main sound";
+ break;
+ case MAIN_SUBTITLE:
+ type_name = " for main subtitle";
+ break;
+ case UNKNOWN:
+ break;
+ }
+
+ _message = String::compose ("Missing asset %1%2", path.string(), type_name);
+}
diff --git a/src/exceptions.h b/src/exceptions.h
index 7446e352..43ddab02 100644
--- a/src/exceptions.h
+++ b/src/exceptions.h
@@ -105,11 +105,31 @@ public:
return _message.c_str ();
}
-private:
+protected:
+ DCPReadError () {}
+
/** error message */
std::string _message;
};
+class MissingAssetError : public DCPReadError
+{
+public:
+ enum AssetType {
+ MAIN_PICTURE,
+ MAIN_SOUND,
+ MAIN_SUBTITLE,
+ UNKNOWN
+ };
+
+ MissingAssetError (boost::filesystem::path, AssetType = UNKNOWN);
+ ~MissingAssetError () throw () {}
+
+private:
+ boost::filesystem::path _path;
+ AssetType _type;
+};
+
/** @class XMLError
* @brief An XML error
*/