summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-09-17 22:31:09 +0200
committerCarl Hetherington <cth@carlh.net>2022-09-17 22:31:09 +0200
commit0f9f004c50a8bea6b87d5a1636f95f67066e5187 (patch)
tree3c6c0f851b492704a580c2a87b8f3738bdd724cc
parentdba3b79e848c70e405e41744c40b416014e86eb8 (diff)
Give a better error if a specified CPL does not exist.
-rw-r--r--src/lib/dcp_examiner.cc10
-rw-r--r--src/lib/exceptions.h9
2 files changed, 14 insertions, 5 deletions
diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc
index 8fa41a8a5..5de8c8905 100644
--- a/src/lib/dcp_examiner.cc
+++ b/src/lib/dcp_examiner.cc
@@ -72,12 +72,12 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
auto cpls = dcp::find_and_resolve_cpls (content->directories(), tolerant);
if (content->cpl ()) {
- /* Use the CPL that the content was using before */
- for (auto i: cpls) {
- if (i->id() == content->cpl().get()) {
- cpl = i;
- }
+ /* Use the CPL that was specified, or that the content was using before */
+ auto iter = std::find_if(cpls.begin(), cpls.end(), [content](shared_ptr<dcp::CPL> cpl) { return cpl->id() == content->cpl().get(); });
+ if (iter == cpls.end()) {
+ throw CPLNotFoundError(content->cpl().get());
}
+ cpl = *iter;
} else {
/* Choose the CPL with the fewest unsatisfied references */
diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h
index 7c9509800..618a03f43 100644
--- a/src/lib/exceptions.h
+++ b/src/lib/exceptions.h
@@ -335,6 +335,15 @@ public:
};
+class CPLNotFoundError : public DCPError
+{
+public:
+ CPLNotFoundError(std::string id)
+ : DCPError(String::compose("CPL %1 not found", id))
+ {}
+};
+
+
class InvalidSignerError : public std::runtime_error
{
public: