2 Copyright (C) 2012-2014 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
29 #include <libavutil/pixfmt.h>
31 #include <boost/filesystem.hpp>
35 /** @class DecodeError
36 * @brief A low-level problem with the decoder (possibly due to the nature
39 class DecodeError : public std::runtime_error
42 explicit DecodeError (std::string s)
43 : std::runtime_error (s)
47 /** @class EncodeError
48 * @brief A low-level problem with an encoder.
50 class EncodeError : public std::runtime_error
53 explicit EncodeError (std::string s)
54 : std::runtime_error (s)
59 * @brief Parent class for file-related errors.
61 class FileError : public std::runtime_error
64 /** @param m Error message.
65 * @param f Name of the file that this exception concerns.
67 FileError (std::string m, boost::filesystem::path f)
68 : std::runtime_error (m)
72 virtual ~FileError () throw () {}
74 /** @return name of the file that this exception concerns */
75 boost::filesystem::path file () const {
80 /** name of the file that this exception concerns */
81 boost::filesystem::path _file;
84 class JoinError : public std::runtime_error
87 explicit JoinError (std::string s)
88 : std::runtime_error (s)
92 /** @class OpenFileError.
93 * @brief Indicates that some error occurred when trying to open a file.
95 class OpenFileError : public FileError
98 /** @param f File that we were trying to open.
99 * @param error Code of error that occurred.
100 * @param reading true if we were opening to read, false if opening to write.
102 OpenFileError (boost::filesystem::path f, int error, bool reading);
105 /** @class ReadFileError.
106 * @brief Indicates that some error occurred when trying to read from a file
108 class ReadFileError : public FileError
111 /** @param f File that we were trying to read from.
112 * @param e errno value, or 0.
114 ReadFileError (boost::filesystem::path f, int e = 0);
117 /** @class WriteFileError.
118 * @brief Indicates that some error occurred when trying to write to a file
120 class WriteFileError : public FileError
123 /** @param f File that we were trying to write to.
124 * @param e errno value, or 0.
126 WriteFileError (boost::filesystem::path f, int e);
129 /** @class SettingError.
130 * @brief Indicates that something is wrong with a setting.
132 class SettingError : public std::runtime_error
135 /** @param s Name of setting that was required.
138 SettingError (std::string s, std::string m)
139 : std::runtime_error (m)
143 virtual ~SettingError () throw () {}
145 /** @return name of setting in question */
146 std::string setting () const {
151 std::string _setting;
154 /** @class MissingSettingError.
155 * @brief Indicates that a Film is missing a setting that is required for some operation.
157 class MissingSettingError : public SettingError
160 /** @param s Name of setting that was required */
161 explicit MissingSettingError (std::string s);
164 /** @class BadSettingError
165 * @brief Indicates that a setting is bad in some way.
167 class BadSettingError : public SettingError
170 /** @param s Name of setting that is bad.
171 * @param m Error message.
173 BadSettingError (std::string s, std::string m)
174 : SettingError (s, m)
178 /** @class NetworkError
179 * @brief Indicates some problem with communication on the network.
181 class NetworkError : public std::runtime_error
184 explicit NetworkError (std::string s)
185 : std::runtime_error (s)
190 * @brief A problem with a KDM.
192 class KDMError : public std::runtime_error
195 KDMError (std::string s, std::string d);
196 ~KDMError () throw() {}
198 std::string summary () const {
202 std::string detail () const {
207 std::string _summary;
211 /** @class PixelFormatError
212 * @brief A problem with an unsupported pixel format.
214 class PixelFormatError : public std::runtime_error
217 PixelFormatError (std::string o, AVPixelFormat f);
220 /** @class TextSubtitleError
221 * @brief An error that occurs while parsing a TextSubtitleError file.
223 class TextSubtitleError : public FileError
226 TextSubtitleError (std::string, std::string, boost::filesystem::path);
229 class DCPError : public std::runtime_error
232 explicit DCPError (std::string s)
233 : std::runtime_error (s)
237 class InvalidSignerError : public std::runtime_error
240 InvalidSignerError ();
241 explicit InvalidSignerError (std::string reason);
244 class ProgrammingError : public std::runtime_error
247 ProgrammingError (std::string file, int line, std::string message = "");
250 class TextEncodingError : public std::runtime_error
253 explicit TextEncodingError (std::string s)
254 : std::runtime_error (s)
258 class MetadataError : public std::runtime_error
261 explicit MetadataError (std::string s)
262 : std::runtime_error (s)
266 class OldFormatError : public std::runtime_error
269 explicit OldFormatError (std::string s)
270 : std::runtime_error (s)
274 class KDMAsContentError : public std::runtime_error
277 KDMAsContentError ();