2 Copyright (C) 2014-2019 Carl Hetherington <cth@carlh.net>
4 This file is part of libdcp.
6 libdcp is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 libdcp is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with libdcp. If not, see <http://www.gnu.org/licenses/>.
19 In addition, as a special exception, the copyright holders give
20 permission to link the code of portions of this program with the
21 OpenSSL library under certain conditions as described in each
22 individual source file, and distribute linked combinations
25 You must obey the GNU General Public License in all respects
26 for all of the code used other than OpenSSL. If you modify
27 file(s) with this exception, you may extend this exception to your
28 version of the file(s), but you are not obligated to do so. If you
29 do not wish to do so, delete this exception statement from your
30 version. If you delete this exception statement from all source
31 files in the program, then also delete it here.
34 /** @file src/exceptions.cc
35 * @brief Exceptions thrown by libdcp.
38 #include "exceptions.h"
39 #include "compose.hpp"
42 using std::runtime_error;
45 FileError::FileError (string message, boost::filesystem::path filename, int number)
46 : runtime_error (String::compose ("%1 (%2) (error %3)", message, filename.string(), number))
47 , _filename (filename)
53 UnresolvedRefError::UnresolvedRefError (string id)
54 : runtime_error (String::compose ("Unresolved reference to asset id %1", id))
59 TimeFormatError::TimeFormatError (string bad_time)
60 : runtime_error (String::compose ("Bad time string %1", bad_time))
65 MissingAssetError::MissingAssetError (boost::filesystem::path path, AssetType type)
67 type == MAIN_PICTURE ? String::compose ("Missing asset %1 for main picture", path.filename().string()) :
68 (type == MAIN_SOUND ? String::compose ("Missing asset %1 for main sound", path.filename().string()) :
69 (type == MAIN_SUBTITLE ? String::compose ("Missing asset %1 for main subtitle", path.filename().string()) :
70 String::compose ("Missing asset %1", path.filename().string()))))
76 BadContentKindError::BadContentKindError (string content_kind)
77 : DCPReadError (String::compose("Bad content kind '%1'", content_kind))
82 NotEncryptedError::NotEncryptedError (string const & what)
83 : runtime_error (String::compose ("%1 is not encrypted", what))
89 ProgrammingError::ProgrammingError (string file, int line)
90 : runtime_error (String::compose ("Programming error at %1:%2", file, line))
95 MismatchedStandardError::MismatchedStandardError ()
96 : DCPReadError ("DCP contains both Interop and SMPTE parts")
101 KDMDecryptionError::KDMDecryptionError (std::string message, int cipher_length, int modulus_dmax)
102 : runtime_error (String::compose ("Could not decrypt KDM (%1) (%2/%3)", message, cipher_length, modulus_dmax))
107 KDMFormatError::KDMFormatError (std::string message)
108 : runtime_error (String::compose ("Could not parse KDM (%1)", message))
113 CertificateChainError::CertificateChainError (string message)
114 : runtime_error (message)
119 DCPReadError::DCPReadError (string message, string detail)
120 : runtime_error(String::compose("%1 (%2)", message, detail))
127 MissingSubtitleImageError::MissingSubtitleImageError (string id)
128 : runtime_error (String::compose("Could not load image for subtitle %1", id))
133 /** The <Path> in the ASSETMAP is empty for asset. I can't see how this is valid,
134 but it's been seen in the wild with a DCP that claims to come from ClipsterDCI 5.10.0.5.
136 EmptyAssetPathError::EmptyAssetPathError (string id)
137 : DCPReadError (String::compose("Asset map path is empty for asset %1", id))