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.
32 /** @class StringError
33 * @brief An exception that uses a std::string to store its error message.
35 class StringError : public std::exception
39 StringError (std::string message)
43 ~StringError () throw () {}
45 /** @return error message */
46 char const * what () const throw () {
47 return _message.c_str ();
55 * @brief An exception related to a file
57 class FileError : public StringError
60 FileError (std::string message, boost::filesystem::path filename, int number);
61 ~FileError () throw () {}
63 /** @return filename of file that was involved */
64 boost::filesystem::path filename () const {
68 /** @return error number of the error */
74 /** filename of file that was involved */
75 boost::filesystem::path _filename;
79 /** @class MXFFileError
80 * @brief An exception related to an MXF file
82 class MXFFileError : public FileError
85 MXFFileError (std::string message, boost::filesystem::path filename, int number)
86 : FileError (message, filename, number)
91 * @brief A miscellaneous exception
93 class MiscError : public StringError
96 MiscError (std::string message)
97 : StringError (message)
101 /** @class DCPReadError
102 * @brief A DCP read exception
104 class DCPReadError : public StringError
107 DCPReadError (std::string message)
108 : StringError (message)
115 /** @class MissingAssetError
116 * @brief An error of a missing asset.
118 class MissingAssetError : public DCPReadError
122 MAIN_PICTURE, //< main picture is missing
123 MAIN_SOUND, //< main sound is missing
124 MAIN_SUBTITLE, //< main subtitle is missing
125 UNKNOWN //< something is missing but we don't know what
128 MissingAssetError (boost::filesystem::path, AssetType = UNKNOWN);
129 ~MissingAssetError () throw () {}
132 boost::filesystem::path _path;
137 * @brief An XML error
139 class XMLError : public StringError
142 XMLError (std::string message)
143 : StringError (message)
147 /** @class UnresolvedRefError
148 * @brief An exception caused by a reference (by UUID) to something which is not known
150 class UnresolvedRefError : public StringError
153 UnresolvedRefError (std::string id);
156 /** @class TimeFormatError
157 * @brief A an error with a string passed to LocalTime.
159 class TimeFormatError : public StringError
162 TimeFormatError (std::string bad_time);
165 /** @class NotEncryptedError
166 * @brief An error raised when creating a DecryptedKDM object for assets that are not
169 class NotEncryptedError : public StringError
172 NotEncryptedError (std::string const & what);
173 ~NotEncryptedError () throw () {}
176 /** @class ProgrammingError
177 * @brief An exception thrown when a DCP_ASSERT fails; something that should not happen.
179 class ProgrammingError : public StringError
182 ProgrammingError (std::string file, int line);