Throw a better error on bad content kind.
authorCarl Hetherington <cth@carlh.net>
Tue, 18 Sep 2018 19:25:21 +0000 (20:25 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 18 Sep 2018 19:25:21 +0000 (20:25 +0100)
src/exceptions.cc
src/exceptions.h
src/util.cc

index 1ded4483485649d97e57200d549a45b20d144cf9..5c486d09c2e05ad2270e6a7bd6900b8df2cdad10 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
@@ -72,6 +72,12 @@ MissingAssetError::MissingAssetError (boost::filesystem::path path, AssetType ty
 
 }
 
+BadContentKindError::BadContentKindError (string content_kind)
+       : DCPReadError (String::compose("Bad content kind '%1'", content_kind))
+{
+
+}
+
 NotEncryptedError::NotEncryptedError (string const & what)
        : runtime_error (String::compose ("%1 is not encrypted", what))
 {
index 8bc6e55054e58662c4756cfafa97b0003dc4417f..d66e89449632eb13a9d8b823464a1b2657446625 100644 (file)
@@ -136,6 +136,12 @@ public:
        ~MissingAssetError () throw () {}
 };
 
+class BadContentKindError : public DCPReadError
+{
+public:
+       BadContentKindError (std::string content_kind);
+};
+
 /** @class XMLError
  *  @brief An XML error
  */
index 3d90ccaa4fe7f6e1155c45cd8e2d6e7ec43e2c88..ac97af6e9d0199f24e28bb8fe7c8b98bcdc77ee2 100644 (file)
@@ -214,7 +214,7 @@ dcp::content_kind_from_string (string kind)
                return ADVERTISEMENT;
        }
 
-       DCP_ASSERT (false);
+       throw BadContentKindError (kind);
 }
 
 /** @param s A string.