libdcp
exceptions.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-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 #include "exceptions.h"
41 #include "compose.hpp"
42 
43 
44 using std::string;
45 using std::runtime_error;
46 using boost::optional;
47 using namespace dcp;
48 
49 
50 FileError::FileError (string message, boost::filesystem::path filename, int number)
51  : runtime_error (String::compose ("%1 (%2) (error %3)", message, filename.string(), number))
52  , _filename (filename)
53  , _number (number)
54 {
55 
56 }
57 
58 
59 UnresolvedRefError::UnresolvedRefError (string id)
60  : runtime_error (String::compose ("Unresolved reference to asset id %1", id))
61 {
62 
63 }
64 
65 
66 TimeFormatError::TimeFormatError (string bad_time)
67  : runtime_error (String::compose ("Bad time string %1", bad_time))
68 {
69 
70 }
71 
72 
73 BadContentKindError::BadContentKindError (string content_kind)
74  : ReadError (String::compose("Bad content kind '%1'", content_kind))
75 {
76 
77 }
78 
79 
80 NotEncryptedError::NotEncryptedError (string const & what)
81  : runtime_error (String::compose ("%1 is not encrypted", what))
82 {
83 
84 }
85 
86 
87 ProgrammingError::ProgrammingError (string file, int line)
88  : runtime_error (String::compose ("Programming error at %1:%2", file, line))
89 {
90 
91 }
92 
93 
94 KDMDecryptionError::KDMDecryptionError (std::string message, int cipher_length, int modulus_dmax)
95  : runtime_error (String::compose ("Could not decrypt KDM (%1) (%2/%3)", message, cipher_length, modulus_dmax))
96 {
97 
98 }
99 
100 
101 KDMFormatError::KDMFormatError (std::string message)
102  : runtime_error (String::compose ("Could not parse KDM (%1)", message))
103 {
104 
105 }
106 
107 
108 CertificateChainError::CertificateChainError (string message)
109  : runtime_error (message)
110 {
111 
112 }
113 
114 
115 ReadError::ReadError (string message, string detail)
116  : runtime_error(String::compose("%1 (%2)", message, detail))
117  , _message(message)
118  , _detail(detail)
119 {
120 
121 }
122 
123 
124 MissingSubtitleImageError::MissingSubtitleImageError (string id)
125  : runtime_error (String::compose("Could not load image for subtitle %1", id))
126 {
127 
128 }
129 
130 
131 BadKDMDateError::BadKDMDateError (bool starts_too_early)
132  : runtime_error (
133  starts_too_early ?
134  "KDM validity period starts before or close to the start of the signing certificate validity period" :
135  "KDM validity ends after or close to the end of the signing certificate's validity period"
136  )
137  , _starts_too_early (starts_too_early)
138 {
139 
140 }
141 
142 
143 StartCompressionError::StartCompressionError (optional<int> code)
144  : runtime_error (String::compose("Could not start JPEG2000 encoding%1", code ? String::compose(" (%1", *code) : ""))
145  , _code (code)
146 {}
147 
148 
149 
150 CombineError::CombineError (string message)
151  : runtime_error (message)
152 {}
153 
154 
155 LanguageTagError::LanguageTagError (std::string message)
156  : runtime_error (message)
157 {}
158 
159 
160 BadSettingError::BadSettingError (std::string message)
161  : runtime_error (message)
162 {
163 
164 }
165 
166 
167 DuplicateIdError::DuplicateIdError (std::string message)
168  : runtime_error (message)
169 {
170 
171 }
172 
173 
174 MainSoundConfigurationError::MainSoundConfigurationError (std::string s)
175  : runtime_error (String::compose("Could not parse MainSoundConfiguration %1", s))
176 {
177 
178 }
179 
180 
181 UnknownChannelIdError::UnknownChannelIdError (std::string id)
182  : runtime_error (String::compose("Unrecognised channel id '%1'", id))
183 {
184 
185 }
186 
187 
188 NoReelsError::NoReelsError ()
189  : runtime_error ("Cannot make a DCP when no reels have been added")
190 {
191 
192 }
193 
194 
195 MissingAssetmapError::MissingAssetmapError (boost::filesystem::path dir)
196  : ReadError (String::compose("Could not find ASSETMAP nor ASSETMAP.xml in '%1'", dir.string()))
197 {
198 
199 }
200 
Any error that occurs when reading data from a DCP.
Definition: exceptions.h:106
Exceptions thrown by libdcp.
Namespace for everything in libdcp.
Definition: array_data.h:50