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 ReadFileError.
121 * @brief Indicates that some error occurred when trying to read from a file
123 class ReadFileError : public FileError
126 /** @param f File that we were trying to read from.
127 * @param e errno value, or 0.
129 ReadFileError (boost::filesystem::path f, int e = 0);
132 /** @class WriteFileError.
133 * @brief Indicates that some error occurred when trying to write to a file
135 class WriteFileError : public FileError
138 /** @param f File that we were trying to write to.
139 * @param e errno value, or 0.
141 WriteFileError (boost::filesystem::path f, int e);
144 /** @class SettingError.
145 * @brief Indicates that something is wrong with a setting.
147 class SettingError : public std::runtime_error
150 /** @param s Name of setting that was required.
153 SettingError (std::string s, std::string m)
154 : std::runtime_error (m)
158 virtual ~SettingError () throw () {}
160 /** @return name of setting in question */
161 std::string setting () const {
166 std::string _setting;
169 /** @class MissingSettingError.
170 * @brief Indicates that a Film is missing a setting that is required for some operation.
172 class MissingSettingError : public SettingError
175 /** @param s Name of setting that was required */
176 explicit MissingSettingError (std::string s);
179 /** @class BadSettingError
180 * @brief Indicates that a setting is bad in some way.
182 class BadSettingError : public SettingError
185 /** @param s Name of setting that is bad.
186 * @param m Error message.
188 BadSettingError (std::string s, std::string m)
189 : SettingError (s, m)
193 /** @class NetworkError
194 * @brief Indicates some problem with communication on the network.
196 class NetworkError : public std::runtime_error
199 explicit NetworkError (std::string s)
200 : std::runtime_error (s)
205 * @brief A problem with a KDM.
207 class KDMError : public std::runtime_error
210 KDMError (std::string s, std::string d);
211 ~KDMError () throw() {}
213 std::string summary () const {
217 std::string detail () const {
222 std::string _summary;
226 /** @class PixelFormatError
227 * @brief A problem with an unsupported pixel format.
229 class PixelFormatError : public std::runtime_error
232 PixelFormatError (std::string o, AVPixelFormat f);
235 /** @class TextSubtitleError
236 * @brief An error that occurs while parsing a TextSubtitleError file.
238 class TextSubtitleError : public FileError
241 TextSubtitleError (std::string, std::string, boost::filesystem::path);
244 class DCPError : public std::runtime_error
247 explicit DCPError (std::string s)
248 : std::runtime_error (s)
252 class InvalidSignerError : public std::runtime_error
255 InvalidSignerError ();
256 explicit InvalidSignerError (std::string reason);
259 class ProgrammingError : public std::runtime_error
262 ProgrammingError (std::string file, int line, std::string message = "");
265 class TextEncodingError : public std::runtime_error
268 explicit TextEncodingError (std::string s)
269 : std::runtime_error (s)
273 class MetadataError : public std::runtime_error
276 explicit MetadataError (std::string s)
277 : std::runtime_error (s)
281 class OldFormatError : public std::runtime_error
284 explicit OldFormatError (std::string s)
285 : std::runtime_error (s)
289 class KDMAsContentError : public std::runtime_error
292 KDMAsContentError ();