libdcp
exceptions.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
3 
4  This file is part of libdcp.
5 
6  libdcp 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.
10 
11  libdcp 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.
15 
16  You should have received a copy of the GNU General Public License
17  along with libdcp. If not, see <http://www.gnu.org/licenses/>.
18 
19  In addition, as a special exception, the copyright holders give
20  permission to link the code of portions of this program with the
21  OpenSSL library under certain conditions as described in each
22  individual source file, and distribute linked combinations
23  including the two.
24 
25  You must obey the GNU General Public License in all respects
26  for all of the code used other than OpenSSL. If you modify
27  file(s) with this exception, you may extend this exception to your
28  version of the file(s), but you are not obligated to do so. If you
29  do not wish to do so, delete this exception statement from your
30  version. If you delete this exception statement from all source
31  files in the program, then also delete it here.
32 */
33 
34 
40 #ifndef LIBDCP_EXCEPTIONS_H
41 #define LIBDCP_EXCEPTIONS_H
42 
43 
44 #include <boost/filesystem.hpp>
45 #include <boost/optional.hpp>
46 
47 
48 namespace dcp
49 {
50 
51 
55 class FileError : public std::runtime_error
56 {
57 public:
58  FileError (std::string message, boost::filesystem::path filename, int number);
59  ~FileError () throw () {}
60 
62  boost::filesystem::path filename () const {
63  return _filename;
64  }
65 
67  int number () const {
68  return _number;
69  }
70 
71 private:
73  boost::filesystem::path _filename;
74  int _number;
75 };
76 
77 
81 class MXFFileError : public FileError
82 {
83 public:
84  MXFFileError (std::string message, boost::filesystem::path filename, int number)
85  : FileError (message, filename, number)
86  {}
87 };
88 
89 
93 class MiscError : public std::runtime_error
94 {
95 public:
96  explicit MiscError (std::string message)
97  : std::runtime_error (message)
98  {}
99 };
100 
101 
105 class ReadError : public std::runtime_error
106 {
107 public:
108  explicit ReadError (std::string message)
109  : std::runtime_error(message)
110  , _message(message)
111  {}
112 
113  ReadError (std::string message, std::string detail);
114 
115  ~ReadError() throw () {}
116 
117  std::string message () const {
118  return _message;
119  }
120 
121  boost::optional<std::string> detail () const {
122  return _detail;
123  }
124 
125 private:
126  std::string _message;
127  boost::optional<std::string> _detail;
128 };
129 
130 
135 {
136 public:
137  explicit J2KDecompressionError (std::string message)
138  : ReadError (message)
139  {}
140 };
141 
142 
144 {
145 public:
146  explicit MPEG2CodecError(std::string message)
147  : MiscError(message)
148  {}
149 };
150 
151 
153 {
154 public:
155  explicit MPEG2DecompressionError(std::string message)
156  : ReadError(message)
157  {}
158 };
159 
160 
162 {
163 public:
164  explicit MPEG2CompressionError(std::string message)
165  : MiscError(message)
166  {}
167 };
168 
169 
171 {
172 public:
173  BadContentKindError (std::string content_kind);
174 };
175 
176 
181 {
182 public:
183  explicit MissingAssetmapError (boost::filesystem::path dir);
184 };
185 
186 
190 class XMLError : public std::runtime_error
191 {
192 public:
193  explicit XMLError (std::string message)
194  : std::runtime_error (message)
195  {}
196 };
197 
198 
202 class UnresolvedRefError : public std::runtime_error
203 {
204 public:
205  explicit UnresolvedRefError (std::string id);
206 };
207 
208 
212 class TimeFormatError : public std::runtime_error
213 {
214 public:
215  explicit TimeFormatError (std::string bad_time);
216 };
217 
218 
223 class NotEncryptedError : public std::runtime_error
224 {
225 public:
226  explicit NotEncryptedError (std::string const & what);
227  ~NotEncryptedError () throw () {}
228 };
229 
230 
234 class ProgrammingError : public std::runtime_error
235 {
236 public:
237  ProgrammingError (std::string file, int line);
238 };
239 
240 
241 class KDMDecryptionError : public std::runtime_error
242 {
243 public:
244  KDMDecryptionError (std::string message, int cipher_length, int modulus_dmax);
245 };
246 
247 
248 class KDMFormatError : public std::runtime_error
249 {
250 public:
251  KDMFormatError (std::string message);
252 };
253 
254 
255 class CertificateChainError : public std::runtime_error
256 {
257 public:
258  CertificateChainError (std::string message);
259 };
260 
261 
262 class MissingTextImageError : public std::runtime_error
263 {
264 public:
265  MissingTextImageError (std::string id);
266 };
267 
268 
269 class BadKDMDateError : public std::runtime_error
270 {
271 public:
272  BadKDMDateError (bool starts_too_early);
273 
274  bool starts_too_early () const {
275  return _starts_too_early;
276  }
277 
278 private:
279  bool _starts_too_early;
280 };
281 
282 
283 class StartCompressionError : public std::runtime_error
284 {
285 public:
286  explicit StartCompressionError (boost::optional<int> code = boost::optional<int>());
287  ~StartCompressionError () throw () {}
288 
289  boost::optional<int> code () const {
290  return _code;
291  }
292 
293 private:
294  boost::optional<int> _code;
295 };
296 
297 
298 class CombineError : public std::runtime_error
299 {
300 public:
301  explicit CombineError (std::string message);
302 };
303 
304 
305 class LanguageTagError : public std::runtime_error
306 {
307 public:
308  LanguageTagError (std::string message);
309 };
310 
311 
312 class BadSettingError : public std::runtime_error
313 {
314 public:
315  BadSettingError (std::string message);
316 };
317 
318 
319 class DuplicateIdError : public std::runtime_error
320 {
321 public:
322  DuplicateIdError (std::string message);
323 };
324 
325 
326 class MainSoundConfigurationError : public std::runtime_error
327 {
328 public:
329  MainSoundConfigurationError (std::string s);
330 };
331 
332 
333 class UnknownChannelIdError : public std::runtime_error
334 {
335 public:
336  UnknownChannelIdError (std::string s);
337 };
338 
339 
340 class NoReelsError : public std::runtime_error
341 {
342 public:
343  NoReelsError ();
344 };
345 
346 
347 class InconsistentValidityPeriodError : public std::runtime_error
348 {
349 public:
351 };
352 
353 
354 class BadURNUUIDError : public std::runtime_error
355 {
356 public:
357  BadURNUUIDError(std::string bad_id);
358 };
359 
360 
361 }
362 
363 
364 #endif
An exception related to a file.
Definition: exceptions.h:56
int number() const
Definition: exceptions.h:67
boost::filesystem::path _filename
Definition: exceptions.h:73
boost::filesystem::path filename() const
Definition: exceptions.h:62
An error that occurs during decompression of JPEG2000 data.
Definition: exceptions.h:135
An exception related to an MXF file.
Definition: exceptions.h:82
A miscellaneous exception.
Definition: exceptions.h:94
Thrown when no ASSETMAP was found when trying to read a DCP.
Definition: exceptions.h:181
An error raised when creating a DecryptedKDM object for assets that are not encrypted.
Definition: exceptions.h:224
An exception thrown when a DCP_ASSERT fails; something that should not happen.
Definition: exceptions.h:235
Any error that occurs when reading data from a DCP.
Definition: exceptions.h:106
A an error with a string passed to LocalTime.
Definition: exceptions.h:213
An exception caused by a reference (by UUID) to something which is not known.
Definition: exceptions.h:203
An XML error.
Definition: exceptions.h:191
Namespace for everything in libdcp.
Definition: array_data.h:50