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 /** @file src/lib/exceptions.h
21 * @brief Our exceptions.
24 #ifndef DCPOMATIC_EXCEPTIONS_H
25 #define DCPOMATIC_EXCEPTIONS_H
28 #include <libavutil/pixfmt.h>
30 #include <boost/filesystem.hpp>
34 /** @class StringError
35 * @brief A parent class for exceptions using messages held in a std::string
37 class StringError : public std::exception
40 /** @param w Error message */
41 StringError (std::string w)
45 virtual ~StringError () throw () {}
47 /** @return error message */
48 char const * what () const throw () {
49 return _what.c_str ();
57 /** @class DecodeError
58 * @brief A low-level problem with the decoder (possibly due to the nature
61 class DecodeError : public StringError
64 DecodeError (std::string s)
69 /** @class EncodeError
70 * @brief A low-level problem with an encoder.
72 class EncodeError : public StringError
75 EncodeError (std::string s)
81 * @brief Parent class for file-related errors.
83 class FileError : public StringError
86 /** @param m Error message.
87 * @param f Name of the file that this exception concerns.
89 FileError (std::string m, boost::filesystem::path f)
94 virtual ~FileError () throw () {}
96 /** @return name of the file that this exception concerns */
97 boost::filesystem::path file () const {
102 /** name of the file that this exception concerns */
103 boost::filesystem::path _file;
106 class JoinError : public StringError
109 JoinError (std::string s)
114 /** @class OpenFileError.
115 * @brief Indicates that some error occurred when trying to open a file.
117 class OpenFileError : public FileError
120 /** @param f File that we were trying to open */
121 OpenFileError (boost::filesystem::path f);
124 /** @class CreateFileError.
125 * @brief Indicates that some error occurred when trying to create a file.
127 class CreateFileError : public FileError
130 /** @param f File that we were trying to create */
131 CreateFileError (boost::filesystem::path f);
135 /** @class ReadFileError.
136 * @brief Indicates that some error occurred when trying to read from a file
138 class ReadFileError : public FileError
141 /** @param f File that we were trying to read from.
142 * @param e errno value, or 0.
144 ReadFileError (boost::filesystem::path f, int e = 0);
147 /** @class WriteFileError.
148 * @brief Indicates that some error occurred when trying to write to a file
150 class WriteFileError : public FileError
153 /** @param f File that we were trying to write to.
154 * @param e errno value, or 0.
156 WriteFileError (boost::filesystem::path f, int e);
159 /** @class SettingError.
160 * @brief Indicates that something is wrong with a setting.
162 class SettingError : public StringError
165 /** @param s Name of setting that was required.
168 SettingError (std::string s, std::string m)
173 virtual ~SettingError () throw () {}
175 /** @return name of setting in question */
176 std::string setting () const {
181 std::string _setting;
184 /** @class MissingSettingError.
185 * @brief Indicates that a Film is missing a setting that is required for some operation.
187 class MissingSettingError : public SettingError
190 /** @param s Name of setting that was required */
191 MissingSettingError (std::string s);
194 /** @class BadSettingError
195 * @brief Indicates that a setting is bad in some way.
197 class BadSettingError : public SettingError
200 /** @param s Name of setting that is bad */
201 BadSettingError (std::string s, std::string m)
202 : SettingError (s, m)
206 /** @class NetworkError
207 * @brief Indicates some problem with communication on the network.
209 class NetworkError : public StringError
212 NetworkError (std::string s)
218 * @brief A problem with a KDM.
220 class KDMError : public StringError
223 KDMError (std::string s)
228 /** @class PixelFormatError
229 * @brief A problem with an unsupported pixel format.
231 class PixelFormatError : public StringError
234 PixelFormatError (std::string o, AVPixelFormat f);
237 /** @class SubRipError
238 * @brief An error that occurs while parsing a SubRip file.
240 class SubRipError : public FileError
243 SubRipError (std::string, std::string, boost::filesystem::path);
246 class DCPError : public StringError
249 DCPError (std::string s)
254 class InvalidSignerError : public StringError
257 InvalidSignerError ();
260 class ProgrammingError : public StringError
263 ProgrammingError (std::string file, int line);
266 class TextEncodingError : public StringError
269 TextEncodingError (std::string s)