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>
33 #include <boost/optional.hpp>
37 /** @class DecodeError
38 * @brief A low-level problem with the decoder (possibly due to the nature
41 class DecodeError : public std::runtime_error
44 explicit DecodeError (std::string s)
45 : std::runtime_error (s)
49 class CryptoError : public std::runtime_error
52 explicit CryptoError (std::string s)
53 : std::runtime_error (s)
57 /** @class EncodeError
58 * @brief A low-level problem with an encoder.
60 class EncodeError : public std::runtime_error
63 explicit EncodeError (std::string s)
64 : std::runtime_error (s)
69 * @brief Parent class for file-related errors.
71 class FileError : public std::runtime_error
74 /** @param m Error message.
75 * @param f Name of the file that this exception concerns.
77 FileError (std::string m, boost::filesystem::path f)
78 : std::runtime_error (String::compose("%1 with %2", m, f.string()))
82 virtual ~FileError () throw () {}
84 /** @return name of the file that this exception concerns */
85 boost::filesystem::path file () const {
90 /** name of the file that this exception concerns */
91 boost::filesystem::path _file;
94 class JoinError : public std::runtime_error
97 explicit JoinError (std::string s)
98 : std::runtime_error (s)
102 /** @class OpenFileError.
103 * @brief Indicates that some error occurred when trying to open a file.
105 class OpenFileError : public FileError
114 /** @param f File that we were trying to open.
115 * @param error Code of error that occurred.
116 * @param mode Mode that we tried to open the file in.
118 OpenFileError (boost::filesystem::path f, int error, Mode mode);
121 class FileNotFoundError : public std::runtime_error
124 FileNotFoundError (boost::filesystem::path f);
125 virtual ~FileNotFoundError () throw () {}
127 /** @return name of the file that this exception concerns */
128 boost::filesystem::path file () const {
133 /** name of the file that this exception concerns */
134 boost::filesystem::path _file;
137 /** @class ReadFileError.
138 * @brief Indicates that some error occurred when trying to read from a file
140 class ReadFileError : public FileError
143 /** @param f File that we were trying to read from.
144 * @param e errno value, or 0.
146 ReadFileError (boost::filesystem::path f, int e = 0);
149 /** @class WriteFileError.
150 * @brief Indicates that some error occurred when trying to write to a file
152 class WriteFileError : public FileError
155 /** @param f File that we were trying to write to.
156 * @param e errno value, or 0.
158 WriteFileError (boost::filesystem::path f, int e);
161 /** @class SettingError.
162 * @brief Indicates that something is wrong with a setting.
164 class SettingError : public std::runtime_error
167 /** @param s Name of setting that was required.
170 SettingError (std::string s, std::string m)
171 : std::runtime_error (m)
175 virtual ~SettingError () throw () {}
177 /** @return name of setting in question */
178 std::string setting () const {
183 std::string _setting;
186 /** @class MissingSettingError.
187 * @brief Indicates that a Film is missing a setting that is required for some operation.
189 class MissingSettingError : public SettingError
192 /** @param s Name of setting that was required */
193 explicit MissingSettingError (std::string s);
196 /** @class BadSettingError
197 * @brief Indicates that a setting is bad in some way.
199 class BadSettingError : public SettingError
202 /** @param s Name of setting that is bad.
203 * @param m Error message.
205 BadSettingError (std::string s, std::string m)
206 : SettingError (s, m)
210 /** @class NetworkError
211 * @brief Indicates some problem with communication on the network.
213 class NetworkError : public std::runtime_error
216 explicit NetworkError (std::string s)
217 : std::runtime_error (s)
222 * @brief A problem with a KDM.
224 class KDMError : public std::runtime_error
227 KDMError (std::string s, std::string d);
228 ~KDMError () throw() {}
230 std::string summary () const {
234 std::string detail () const {
239 std::string _summary;
243 /** @class PixelFormatError
244 * @brief A problem with an unsupported pixel format.
246 class PixelFormatError : public std::runtime_error
249 PixelFormatError (std::string o, AVPixelFormat f);
252 /** @class TextSubtitleError
253 * @brief An error that occurs while parsing a TextSubtitleError file.
255 class TextSubtitleError : public FileError
258 TextSubtitleError (std::string, std::string, boost::filesystem::path);
261 class DCPError : public std::runtime_error
264 explicit DCPError (std::string s)
265 : std::runtime_error (s)
269 class InvalidSignerError : public std::runtime_error
272 InvalidSignerError ();
273 explicit InvalidSignerError (std::string reason);
276 class ProgrammingError : public std::runtime_error
279 ProgrammingError (std::string file, int line, std::string message = "");
282 class TextEncodingError : public std::runtime_error
285 explicit TextEncodingError (std::string s)
286 : std::runtime_error (s)
290 class MetadataError : public std::runtime_error
293 explicit MetadataError (std::string s)
294 : std::runtime_error (s)
298 class OldFormatError : public std::runtime_error
301 explicit OldFormatError (std::string s)
302 : std::runtime_error (s)
306 class KDMAsContentError : public std::runtime_error
309 KDMAsContentError ();
312 class GLError : public std::runtime_error
315 GLError (char const * last, int e);
319 * @brief An error which occurs when copying a DCP to a distribution drive.
321 class CopyError : public std::runtime_error
324 CopyError (std::string s, boost::optional<int> n = boost::optional<int>());
325 virtual ~CopyError () throw () {}
327 std::string message () const {
331 boost::optional<int> number () const {
336 std::string _message;
337 boost::optional<int> _number;
341 /** @class CommunicationFailedError
342 * @brief Communcation between dcpomatic2_disk and _disk_writer failed somehow.
344 class CommunicationFailedError : public CopyError
347 CommunicationFailedError ();
351 /** @class VerifyError
352 * @brief An error which occurs when verifying a DCP that we copied to a distribution drive.
354 class VerifyError : public std::runtime_error
357 VerifyError (std::string s, int n);
358 virtual ~VerifyError () throw () {}
360 std::string message () const {
364 int number () const {
369 std::string _message;