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::exception
38 FileError (std::string message, boost::filesystem::path filename, int number);
39 ~FileError () throw () {}
41 /** @return error message */
42 char const * what () const throw () {
43 return _message.c_str ();
46 /** @return filename of file that was involved */
47 boost::filesystem::path filename () const {
51 /** @return error number of the error */
59 /** filename of file that was involved */
60 boost::filesystem::path _filename;
64 /** @class MXFFileError
65 * @brief An exception related to an MXF file
67 class MXFFileError : public FileError
70 MXFFileError (std::string message, boost::filesystem::path filename, int number)
71 : FileError (message, filename, number)
76 * @brief A miscellaneous exception
78 class MiscError : public std::exception
81 MiscError (std::string message) : _message (message) {}
82 ~MiscError () throw () {}
84 /** @return error message */
85 char const * what () const throw () {
86 return _message.c_str ();
94 /** @class DCPReadError
95 * @brief A DCP read exception
97 class DCPReadError : public std::exception
100 DCPReadError (std::string message) : _message (message) {}
101 ~DCPReadError () throw () {}
103 /** @return error message */
104 char const * what () const throw () {
105 return _message.c_str ();
112 std::string _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 std::exception
142 XMLError (std::string message) : _message (message) {}
143 ~XMLError () throw () {}
145 /** @return error message */
146 char const * what () const throw () {
147 return _message.c_str ();
152 std::string _message;
155 /** @class UnresolvedRefError
156 * @brief An exception caused by a reference (by UUID) to something which is not known
158 class UnresolvedRefError : public std::exception
161 UnresolvedRefError (std::string id);
162 ~UnresolvedRefError () throw () {}
164 /** @return error message */
165 char const * what () const throw () {
166 return _message.c_str ();
170 std::string _message;
173 /** @class TimeFormatError
174 * @brief A an error with a string passed to LocalTime.
176 class TimeFormatError : public std::exception
179 TimeFormatError (std::string bad_time);
180 ~TimeFormatError () throw () {}
182 /** @return error message */
183 char const * what () const throw () {
184 return _message.c_str ();
188 std::string _message;