2 Copyright (C) 2012-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 #ifndef LIBDCP_EXCEPTIONS_H
35 #define LIBDCP_EXCEPTIONS_H
37 #include <boost/filesystem.hpp>
38 #include <boost/optional.hpp>
40 /** @file src/exceptions.h
41 * @brief Exceptions thrown by libdcp.
48 * @brief An exception related to a file
50 class FileError : public std::runtime_error
53 FileError (std::string message, boost::filesystem::path filename, int number);
54 ~FileError () throw () {}
56 /** @return filename of file that was involved */
57 boost::filesystem::path filename () const {
61 /** @return error number of the error */
67 /** filename of file that was involved */
68 boost::filesystem::path _filename;
72 /** @class MXFFileError
73 * @brief An exception related to an MXF file
75 class MXFFileError : public FileError
78 MXFFileError (std::string message, boost::filesystem::path filename, int number)
79 : FileError (message, filename, number)
84 * @brief A miscellaneous exception
86 class MiscError : public std::runtime_error
89 explicit MiscError (std::string message)
90 : std::runtime_error (message)
94 /** @class DCPReadError
95 * @brief A DCP read exception
97 class DCPReadError : public std::runtime_error
100 explicit DCPReadError (std::string message)
101 : std::runtime_error(message)
105 DCPReadError (std::string message, std::string detail);
107 ~DCPReadError() throw () {}
109 std::string message () const {
113 boost::optional<std::string> detail () const {
118 std::string _message;
119 boost::optional<std::string> _detail;
122 class BadContentKindError : public DCPReadError
125 BadContentKindError (std::string content_kind);
129 * @brief An XML error
131 class XMLError : public std::runtime_error
134 explicit XMLError (std::string message)
135 : std::runtime_error (message)
139 /** @class UnresolvedRefError
140 * @brief An exception caused by a reference (by UUID) to something which is not known
142 class UnresolvedRefError : public std::runtime_error
145 explicit UnresolvedRefError (std::string id);
148 /** @class TimeFormatError
149 * @brief A an error with a string passed to LocalTime.
151 class TimeFormatError : public std::runtime_error
154 explicit TimeFormatError (std::string bad_time);
157 /** @class NotEncryptedError
158 * @brief An error raised when creating a DecryptedKDM object for assets that are not
161 class NotEncryptedError : public std::runtime_error
164 explicit NotEncryptedError (std::string const & what);
165 ~NotEncryptedError () throw () {}
168 /** @class ProgrammingError
169 * @brief An exception thrown when a DCP_ASSERT fails; something that should not happen.
171 class ProgrammingError : public std::runtime_error
174 ProgrammingError (std::string file, int line);
177 class KDMDecryptionError : public std::runtime_error
180 KDMDecryptionError (std::string message, int cipher_length, int modulus_dmax);
183 class KDMFormatError : public std::runtime_error
186 KDMFormatError (std::string message);
189 class CertificateChainError : public std::runtime_error
192 CertificateChainError (std::string message);
195 class MissingSubtitleImageError : public std::runtime_error
198 MissingSubtitleImageError (std::string id);
201 class BadKDMDateError : public std::runtime_error
204 BadKDMDateError (bool starts_too_early);
206 bool starts_too_early () const {
207 return _starts_too_early;
211 bool _starts_too_early;
215 class StartCompressionError : public std::runtime_error
218 explicit StartCompressionError (boost::optional<int> code = boost::optional<int>());
220 boost::optional<int> code () const {
225 boost::optional<int> _code;