Fix confusing error on trying to load a DoM project into the player (#1948).
authorCarl Hetherington <cth@carlh.net>
Sun, 4 Apr 2021 22:51:29 +0000 (00:51 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 4 Apr 2021 22:51:29 +0000 (00:51 +0200)
src/lib/dcp_content.cc
src/lib/exceptions.h
src/tools/dcpomatic_player.cc
src/wx/content_panel.cc

index 318e3ce5288aafad628b952f40a0b23112b0c0a7..256112eb27caaa8a6ba1ac0a5ef6d7fb90629c4c 100644 (file)
@@ -186,10 +186,7 @@ DCPContent::read_directory (boost::filesystem::path p)
                if (!have_metadata) {
                        throw DCPError ("No ASSETMAP or ASSETMAP.xml file found: is this a DCP?");
                } else {
-                       throw DCPError (
-                               "This looks like a DCP-o-matic project folder, which cannot be added to a different project.  "
-                               "Choose the DCP directory inside the DCP-o-matic project folder if that's what you want to import."
-                               );
+                       throw ProjectFolderError ();
                }
        }
 
index 05cda9659f2c63a5b104d6fccbe896e0294e4457..c64f561a837ef478322fa53053ee8c5c8495adb1 100644 (file)
@@ -266,6 +266,21 @@ public:
        {}
 };
 
+
+/** @class ProjectFolderError
+ *  @brief An attempt has been made to read a DCP from a directory, but it looks
+ *  like the directory actually contains a DCP-o-matic project.
+ */
+class ProjectFolderError : public DCPError
+{
+public:
+       /* Code which catches this exception will provide their own message */
+       ProjectFolderError ()
+               : DCPError ("dummy")
+       {}
+};
+
+
 class InvalidSignerError : public std::runtime_error
 {
 public:
index 72ac93cc75a48716782f2ef57c2df206607a17f5..77e48ce0c1d90f716176e7d635c62a9b1cd4637f 100644 (file)
@@ -352,6 +352,7 @@ public:
                reset_film ();
                try {
                        _stress.set_suspended (true);
+                       // here
                        auto dcp = make_shared<DCPContent>(dir);
                        auto job = make_shared<ExamineContentJob>(_film, dcp);
                        _examine_job_connection = job->Finished.connect(bind(&DOMFrame::add_dcp_to_film, this, weak_ptr<Job>(job), weak_ptr<Content>(dcp)));
@@ -361,6 +362,15 @@ public:
                                return;
                        }
                        Config::instance()->add_to_player_history (dir);
+               } catch (ProjectFolderError &) {
+                       error_dialog (
+                               this,
+                               wxString::Format(_("Could not load a DCP from %s"), std_to_wx(dir.string())),
+                               _(
+                                       "This looks like a DCP-o-matic project folder, which cannot be loaded into the player.  "
+                                       "Choose the DCP directory inside the DCP-o-matic project folder if that's what you want to play."
+                                )
+                               );
                } catch (dcp::ReadError& e) {
                        error_dialog (this, wxString::Format(_("Could not load a DCP from %s"), std_to_wx(dir.string())), std_to_wx(e.what()));
                } catch (DCPError& e) {
index 7789e7b786b4fc8366b3d10f32d24d21bf1406a9..d1859b894e1c34a8f391ed7dc0c19b9daedf2ade 100644 (file)
@@ -511,6 +511,14 @@ ContentPanel::add_dcp_clicked ()
 
        try {
                _film->examine_and_add_content (make_shared<DCPContent>(path));
+       } catch (ProjectFolderError &) {
+               error_dialog (
+                       _parent,
+                       _(
+                               "This looks like a DCP-o-matic project folder, which cannot be added to a different project.  "
+                               "Choose the DCP directory inside the DCP-o-matic project folder if that's what you want to import."
+                        )
+                       );
        } catch (exception& e) {
                error_dialog (_parent, e.what());
        }