2 Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 /** @file src/lib/exceptions.h
22 * @brief Our exceptions.
25 #ifndef DCPOMATIC_EXCEPTIONS_H
26 #define DCPOMATIC_EXCEPTIONS_H
28 #include "compose.hpp"
30 #include <libavutil/pixfmt.h>
32 #include <boost/filesystem.hpp>
36 /** @class DecodeError
37 * @brief A low-level problem with the decoder (possibly due to the nature
40 class DecodeError : public std::runtime_error
43 explicit DecodeError (std::string s)
44 : std::runtime_error (s)
48 class CryptoError : public std::runtime_error
51 explicit CryptoError (std::string s)
52 : std::runtime_error (s)
56 /** @class EncodeError
57 * @brief A low-level problem with an encoder.
59 class EncodeError : public std::runtime_error
62 explicit EncodeError (std::string s)
63 : std::runtime_error (s)
68 * @brief Parent class for file-related errors.
70 class FileError : public std::runtime_error
73 /** @param m Error message.
74 * @param f Name of the file that this exception concerns.
76 FileError (std::string m, boost::filesystem::path f)
77 : std::runtime_error (String::compose("%1 with %2", m, f.string()))
81 virtual ~FileError () throw () {}
83 /** @return name of the file that this exception concerns */
84 boost::filesystem::path file () const {
89 /** name of the file that this exception concerns */
90 boost::filesystem::path _file;
93 class JoinError : public std::runtime_error
96 explicit JoinError (std::string s)
97 : std::runtime_error (s)
101 /** @class OpenFileError.
102 * @brief Indicates that some error occurred when trying to open a file.
104 class OpenFileError : public FileError
113 /** @param f File that we were trying to open.
114 * @param error Code of error that occurred.
115 * @param mode Mode that we tried to open the file in.
117 OpenFileError (boost::filesystem::path f, int error, Mode mode);
120 class FileNotFoundError : public std::runtime_error
123 FileNotFoundError (boost::filesystem::path f);
124 virtual ~FileNotFoundError () throw () {}
126 /** @return name of the file that this exception concerns */
127 boost::filesystem::path file () const {
132 /** name of the file that this exception concerns */
133 boost::filesystem::path _file;
136 /** @class ReadFileError.
137 * @brief Indicates that some error occurred when trying to read from a file
139 class ReadFileError : public FileError
142 /** @param f File that we were trying to read from.
143 * @param e errno value, or 0.
145 ReadFileError (boost::filesystem::path f, int e = 0);
148 /** @class WriteFileError.
149 * @brief Indicates that some error occurred when trying to write to a file
151 class WriteFileError : public FileError
154 /** @param f File that we were trying to write to.
155 * @param e errno value, or 0.
157 WriteFileError (boost::filesystem::path f, int e);
160 /** @class SettingError.
161 * @brief Indicates that something is wrong with a setting.
163 class SettingError : public std::runtime_error
166 /** @param s Name of setting that was required.
169 SettingError (std::string s, std::string m)
170 : std::runtime_error (m)
174 virtual ~SettingError () throw () {}
176 /** @return name of setting in question */
177 std::string setting () const {
182 std::string _setting;
185 /** @class MissingSettingError.
186 * @brief Indicates that a Film is missing a setting that is required for some operation.
188 class MissingSettingError : public SettingError
191 /** @param s Name of setting that was required */
192 explicit MissingSettingError (std::string s);
195 /** @class BadSettingError
196 * @brief Indicates that a setting is bad in some way.
198 class BadSettingError : public SettingError
201 /** @param s Name of setting that is bad.
202 * @param m Error message.
204 BadSettingError (std::string s, std::string m)
205 : SettingError (s, m)
209 /** @class NetworkError
210 * @brief Indicates some problem with communication on the network.
212 class NetworkError : public std::runtime_error
215 explicit NetworkError (std::string s)
216 : std::runtime_error (s)
221 * @brief A problem with a KDM.
223 class KDMError : public std::runtime_error
226 KDMError (std::string s, std::string d);
227 ~KDMError () throw() {}
229 std::string summary () const {
233 std::string detail () const {
238 std::string _summary;
242 /** @class PixelFormatError
243 * @brief A problem with an unsupported pixel format.
245 class PixelFormatError : public std::runtime_error
248 PixelFormatError (std::string o, AVPixelFormat f);
251 /** @class TextSubtitleError
252 * @brief An error that occurs while parsing a TextSubtitleError file.
254 class TextSubtitleError : public FileError
257 TextSubtitleError (std::string, std::string, boost::filesystem::path);
260 class DCPError : public std::runtime_error
263 explicit DCPError (std::string s)
264 : std::runtime_error (s)
268 class InvalidSignerError : public std::runtime_error
271 InvalidSignerError ();
272 explicit InvalidSignerError (std::string reason);
275 class ProgrammingError : public std::runtime_error
278 ProgrammingError (std::string file, int line, std::string message = "");
281 class TextEncodingError : public std::runtime_error
284 explicit TextEncodingError (std::string s)
285 : std::runtime_error (s)
289 class MetadataError : public std::runtime_error
292 explicit MetadataError (std::string s)
293 : std::runtime_error (s)
297 class OldFormatError : public std::runtime_error
300 explicit OldFormatError (std::string s)
301 : std::runtime_error (s)
305 class KDMAsContentError : public std::runtime_error
308 KDMAsContentError ();
311 class GLError : public std::runtime_error
314 GLError (char const * last, int e);