2 Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef LIBDCP_EXCEPTIONS_H
21 #define LIBDCP_EXCEPTIONS_H
23 #include <boost/filesystem.hpp>
25 /** @file src/exceptions.h
26 * @brief Exceptions thrown by libdcp.
33 * @brief An exception related to a file
35 class FileError : public std::runtime_error
38 FileError (std::string message, boost::filesystem::path filename, int number);
39 ~FileError () throw () {}
41 /** @return filename of file that was involved */
42 boost::filesystem::path filename () const {
46 /** @return error number of the error */
52 /** filename of file that was involved */
53 boost::filesystem::path _filename;
57 /** @class MXFFileError
58 * @brief An exception related to an MXF file
60 class MXFFileError : public FileError
63 MXFFileError (std::string message, boost::filesystem::path filename, int number)
64 : FileError (message, filename, number)
69 * @brief A miscellaneous exception
71 class MiscError : public std::runtime_error
74 MiscError (std::string message)
75 : std::runtime_error (message)
79 /** @class DCPReadError
80 * @brief A DCP read exception
82 class DCPReadError : public std::runtime_error
85 DCPReadError (std::string message)
86 : std::runtime_error (message)
90 /** @class MissingAssetError
91 * @brief An error of a missing asset.
93 class MissingAssetError : public DCPReadError
97 MAIN_PICTURE, //< main picture is missing
98 MAIN_SOUND, //< main sound is missing
99 MAIN_SUBTITLE, //< main subtitle is missing
100 UNKNOWN //< something is missing but we don't know what
103 MissingAssetError (boost::filesystem::path, AssetType = UNKNOWN);
104 ~MissingAssetError () throw () {}
108 * @brief An XML error
110 class XMLError : public std::runtime_error
113 XMLError (std::string message)
114 : std::runtime_error (message)
118 /** @class UnresolvedRefError
119 * @brief An exception caused by a reference (by UUID) to something which is not known
121 class UnresolvedRefError : public std::runtime_error
124 UnresolvedRefError (std::string id);
127 /** @class TimeFormatError
128 * @brief A an error with a string passed to LocalTime.
130 class TimeFormatError : public std::runtime_error
133 TimeFormatError (std::string bad_time);
136 /** @class NotEncryptedError
137 * @brief An error raised when creating a DecryptedKDM object for assets that are not
140 class NotEncryptedError : public std::runtime_error
143 NotEncryptedError (std::string const & what);
144 ~NotEncryptedError () throw () {}
147 /** @class ProgrammingError
148 * @brief An exception thrown when a DCP_ASSERT fails; something that should not happen.
150 class ProgrammingError : public std::runtime_error
153 ProgrammingError (std::string file, int line);
156 class MismatchedStandardError : public DCPReadError
159 MismatchedStandardError ();