diff options
| author | Carl Hetherington <cth@carlh.net> | 2017-05-24 12:47:36 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2017-05-24 12:47:36 +0100 |
| commit | 98c2cae73faf52dc346758e893f7e38d2c349c03 (patch) | |
| tree | f54f9d62ac94960586c1f6ff999838ec25f5a240 /src | |
| parent | 14fe126396241dc1bde571bd57e76e82f8cf4240 (diff) | |
Better exception when loading a KDM fails.
Diffstat (limited to 'src')
| -rw-r--r-- | src/encrypted_kdm.cc | 13 | ||||
| -rw-r--r-- | src/exceptions.cc | 6 | ||||
| -rw-r--r-- | src/exceptions.h | 6 |
3 files changed, 21 insertions, 4 deletions
diff --git a/src/encrypted_kdm.cc b/src/encrypted_kdm.cc index b6a992fb..054162cc 100644 --- a/src/encrypted_kdm.cc +++ b/src/encrypted_kdm.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2017 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -34,6 +34,7 @@ #include "encrypted_kdm.h" #include "util.h" #include "certificate_chain.h" +#include "exceptions.h" #include <libcxml/cxml.h> #include <libxml++/document.h> #include <libxml++/nodes/element.h> @@ -525,9 +526,13 @@ public: EncryptedKDM::EncryptedKDM (string s) { - shared_ptr<cxml::Document> doc (new cxml::Document ("DCinemaSecurityMessage")); - doc->read_string (s); - _data = new data::EncryptedKDMData (doc); + try { + shared_ptr<cxml::Document> doc (new cxml::Document ("DCinemaSecurityMessage")); + doc->read_string (s); + _data = new data::EncryptedKDMData (doc); + } catch (xmlpp::parse_error& e) { + throw KDMFormatError (e.what ()); + } } EncryptedKDM::EncryptedKDM ( diff --git a/src/exceptions.cc b/src/exceptions.cc index b541beda..fbd8c85f 100644 --- a/src/exceptions.cc +++ b/src/exceptions.cc @@ -96,3 +96,9 @@ KDMDecryptionError::KDMDecryptionError (std::string message) { } + +KDMFormatError::KDMFormatError (std::string message) + : runtime_error (String::compose ("Could not parse KDM (%1)", message)) +{ + +} diff --git a/src/exceptions.h b/src/exceptions.h index 2688ee86..ed77ae3a 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -179,6 +179,12 @@ public: KDMDecryptionError (std::string message); }; +class KDMFormatError : public std::runtime_error +{ +public: + KDMFormatError (std::string message); +}; + } #endif |
