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 : public std::exception
36 StringError (std::string message)
40 ~StringError () throw () {}
42 /** @return error message */
43 char const * what () const throw () {
44 return _message.c_str ();
52 * @brief An exception related to a file
54 class FileError : public StringError
57 FileError (std::string message, boost::filesystem::path filename, int number);
58 ~FileError () throw () {}
60 /** @return filename of file that was involved */
61 boost::filesystem::path filename () const {
65 /** @return error number of the error */
71 /** filename of file that was involved */
72 boost::filesystem::path _filename;
76 /** @class MXFFileError
77 * @brief An exception related to an MXF file
79 class MXFFileError : public FileError
82 MXFFileError (std::string message, boost::filesystem::path filename, int number)
83 : FileError (message, filename, number)
88 * @brief A miscellaneous exception
90 class MiscError : public StringError
93 MiscError (std::string message)
94 : StringError (message)
98 /** @class DCPReadError
99 * @brief A DCP read exception
101 class DCPReadError : public StringError
104 DCPReadError (std::string message)
105 : StringError (message)
112 /** @class MissingAssetError
113 * @brief An error of a missing asset.
115 class MissingAssetError : public DCPReadError
119 MAIN_PICTURE, //< main picture is missing
120 MAIN_SOUND, //< main sound is missing
121 MAIN_SUBTITLE, //< main subtitle is missing
122 UNKNOWN //< something is missing but we don't know what
125 MissingAssetError (boost::filesystem::path, AssetType = UNKNOWN);
126 ~MissingAssetError () throw () {}
129 boost::filesystem::path _path;
134 * @brief An XML error
136 class XMLError : public StringError
139 XMLError (std::string message)
140 : StringError (message)
144 /** @class UnresolvedRefError
145 * @brief An exception caused by a reference (by UUID) to something which is not known
147 class UnresolvedRefError : public StringError
150 UnresolvedRefError (std::string id);
153 /** @class TimeFormatError
154 * @brief A an error with a string passed to LocalTime.
156 class TimeFormatError : public StringError
159 TimeFormatError (std::string bad_time);
162 class NotEncryptedError : public StringError
165 NotEncryptedError (std::string const & what);
166 ~NotEncryptedError () throw () {}
169 class ProgrammingError : public StringError
172 ProgrammingError (std::string file, int line);