2 Copyright (C) 2012-2021 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.
35 /** @file src/exceptions.h
36 * @brief Exceptions thrown by libdcp
40 #ifndef LIBDCP_EXCEPTIONS_H
41 #define LIBDCP_EXCEPTIONS_H
44 #include <boost/filesystem.hpp>
45 #include <boost/optional.hpp>
53 * @brief An exception related to a file
55 class FileError : public std::runtime_error
58 FileError (std::string message, boost::filesystem::path filename, int number);
59 ~FileError () throw () {}
61 /** @return filename of file that was involved */
62 boost::filesystem::path filename () const {
66 /** @return error number of the error */
72 /** filename of file that was involved */
73 boost::filesystem::path _filename;
78 /** @class MXFFileError
79 * @brief An exception related to an MXF file
81 class MXFFileError : public FileError
84 MXFFileError (std::string message, boost::filesystem::path filename, int number)
85 : FileError (message, filename, number)
91 * @brief A miscellaneous exception
93 class MiscError : public std::runtime_error
96 explicit MiscError (std::string message)
97 : std::runtime_error (message)
103 * @brief Any error that occurs when reading data from a DCP
105 class ReadError : public std::runtime_error
108 explicit ReadError (std::string message)
109 : std::runtime_error(message)
113 ReadError (std::string message, std::string detail);
115 ~ReadError() throw () {}
117 std::string message () const {
121 boost::optional<std::string> detail () const {
126 std::string _message;
127 boost::optional<std::string> _detail;
131 /** @class J2KDecompressionError
132 * @brief An error that occurs during decompression of JPEG2000 data
134 class J2KDecompressionError : public ReadError
137 explicit J2KDecompressionError (std::string message)
138 : ReadError (message)
143 class MPEG2CodecError : public MiscError
146 explicit MPEG2CodecError(std::string message)
152 class MPEG2DecompressionError : public ReadError
155 explicit MPEG2DecompressionError(std::string message)
161 class BadContentKindError : public ReadError
164 BadContentKindError (std::string content_kind);
168 /** @class MissingAssetmapError
169 * @brief Thrown when no ASSETMAP was found when trying to read a DCP
171 class MissingAssetmapError : public ReadError
174 explicit MissingAssetmapError (boost::filesystem::path dir);
179 * @brief An XML error
181 class XMLError : public std::runtime_error
184 explicit XMLError (std::string message)
185 : std::runtime_error (message)
190 /** @class UnresolvedRefError
191 * @brief An exception caused by a reference (by UUID) to something which is not known
193 class UnresolvedRefError : public std::runtime_error
196 explicit UnresolvedRefError (std::string id);
200 /** @class TimeFormatError
201 * @brief A an error with a string passed to LocalTime
203 class TimeFormatError : public std::runtime_error
206 explicit TimeFormatError (std::string bad_time);
210 /** @class NotEncryptedError
211 * @brief An error raised when creating a DecryptedKDM object for assets that are not
214 class NotEncryptedError : public std::runtime_error
217 explicit NotEncryptedError (std::string const & what);
218 ~NotEncryptedError () throw () {}
222 /** @class ProgrammingError
223 * @brief An exception thrown when a DCP_ASSERT fails; something that should not happen
225 class ProgrammingError : public std::runtime_error
228 ProgrammingError (std::string file, int line);
232 class KDMDecryptionError : public std::runtime_error
235 KDMDecryptionError (std::string message, int cipher_length, int modulus_dmax);
239 class KDMFormatError : public std::runtime_error
242 KDMFormatError (std::string message);
246 class CertificateChainError : public std::runtime_error
249 CertificateChainError (std::string message);
253 class MissingSubtitleImageError : public std::runtime_error
256 MissingSubtitleImageError (std::string id);
260 class BadKDMDateError : public std::runtime_error
263 BadKDMDateError (bool starts_too_early);
265 bool starts_too_early () const {
266 return _starts_too_early;
270 bool _starts_too_early;
274 class StartCompressionError : public std::runtime_error
277 explicit StartCompressionError (boost::optional<int> code = boost::optional<int>());
278 ~StartCompressionError () throw () {}
280 boost::optional<int> code () const {
285 boost::optional<int> _code;
289 class CombineError : public std::runtime_error
292 explicit CombineError (std::string message);
296 class LanguageTagError : public std::runtime_error
299 LanguageTagError (std::string message);
303 class BadSettingError : public std::runtime_error
306 BadSettingError (std::string message);
310 class DuplicateIdError : public std::runtime_error
313 DuplicateIdError (std::string message);
317 class MainSoundConfigurationError : public std::runtime_error
320 MainSoundConfigurationError (std::string s);
324 class UnknownChannelIdError : public std::runtime_error
327 UnknownChannelIdError (std::string s);
331 class NoReelsError : public std::runtime_error
338 class InconsistentValidityPeriodError : public std::runtime_error
341 InconsistentValidityPeriodError();
345 class BadURNUUIDError : public std::runtime_error
348 BadURNUUIDError(std::string bad_id);