OpenShot Library | libopenshot 0.2.7
Exceptions.h
Go to the documentation of this file.
1/**
2 * @file
3 * @brief Header file for all Exception classes
4 * @author Jonathan Thomas <jonathan@openshot.org>
5 *
6 * @ref License
7 */
8
9/* LICENSE
10 *
11 * Copyright (c) 2008-2019 OpenShot Studios, LLC
12 * <http://www.openshotstudios.com/>. This file is part of
13 * OpenShot Library (libopenshot), an open-source project dedicated to
14 * delivering high quality video editing and animation solutions to the
15 * world. For more information visit <http://www.openshot.org/>.
16 *
17 * OpenShot Library (libopenshot) is free software: you can redistribute it
18 * and/or modify it under the terms of the GNU Lesser General Public License
19 * as published by the Free Software Foundation, either version 3 of the
20 * License, or (at your option) any later version.
21 *
22 * OpenShot Library (libopenshot) is distributed in the hope that it will be
23 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU Lesser General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public License
28 * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
29 */
30
31#ifndef OPENSHOT_EXCEPTIONS_H
32#define OPENSHOT_EXCEPTIONS_H
33
34#include <string>
35
36namespace openshot {
37
38 /**
39 * @brief Base exception class with a custom message variable.
40 *
41 * A std::exception-derived exception class with custom message.
42 * All OpenShot exception classes inherit from this class.
43 */
44 class ExceptionBase : public std::exception
45 {
46 protected:
47 std::string m_message;
48 public:
49 ExceptionBase(std::string message) : m_message(message) { }
50 virtual ~ExceptionBase() noexcept {}
51 virtual const char* what() const noexcept {
52 // return custom message
53 return m_message.c_str();
54 }
55 };
56
57 /// Exception when a required chunk is missing
59 {
60 public:
61 int64_t frame_number;
62 int64_t chunk_number;
63 int64_t chunk_frame;
64 /**
65 * @brief Constructor
66 *
67 * @param message A message to accompany the exception
68 * @param frame_number The frame number being processed
69 * @param chunk_number The chunk requested
70 * @param chunk_frame The chunk frame
71 */
72 ChunkNotFound(std::string message, int64_t frame_number, int64_t chunk_number, int64_t chunk_frame)
74 virtual ~ChunkNotFound() noexcept {}
75 };
76
77
78 /// Exception when accessing a blackmagic decklink card
80 {
81 public:
82 /**
83 * @brief Constructor
84 *
85 * @param message A message to accompany the exception
86 */
87 DecklinkError(std::string message)
88 : ExceptionBase(message) { }
89 virtual ~DecklinkError() noexcept {}
90 };
91
92 /// Exception when decoding audio packet
94 {
95 public:
96 int64_t frame_number;
97 /**
98 * @brief Constructor
99 *
100 * @param message A message to accompany the exception
101 * @param frame_number The frame number being processed
102 */
103 ErrorDecodingAudio(std::string message, int64_t frame_number)
105 virtual ~ErrorDecodingAudio() noexcept {}
106 };
107
108 /// Exception when encoding audio packet
110 {
111 public:
113 /**
114 * @brief Constructor
115 *
116 * @param message A message to accompany the exception
117 * @param frame_number The frame number being processed
118 */
119 ErrorEncodingAudio(std::string message, int64_t frame_number)
121 virtual ~ErrorEncodingAudio() noexcept {}
122 };
123
124 /// Exception when encoding audio packet
126 {
127 public:
129 /**
130 * @brief Constructor
131 *
132 * @param message A message to accompany the exception
133 * @param frame_number The frame number being processed
134 */
135 ErrorEncodingVideo(std::string message, int64_t frame_number)
137 virtual ~ErrorEncodingVideo() noexcept {}
138 };
139
140 /// Exception when an invalid # of audio channels are detected
142 {
143 public:
144 std::string file_path;
145 /**
146 * @brief Constructor
147 *
148 * @param message A message to accompany the exception
149 * @param file_path (optional) The input file being processed
150 */
151 InvalidChannels(std::string message, std::string file_path="")
152 : ExceptionBase(message), file_path(file_path) { }
153 virtual ~InvalidChannels() noexcept {}
154 };
155
156 /// Exception when no valid codec is found for a file
158 {
159 public:
160 std::string file_path;
161 /**
162 * @brief Constructor
163 *
164 * @param message A message to accompany the exception
165 * @param file_path (optional) The input file being processed
166 */
167 InvalidCodec(std::string message, std::string file_path="")
168 : ExceptionBase(message), file_path(file_path) { }
169 virtual ~InvalidCodec() noexcept {}
170 };
171
172 /// Exception for files that can not be found or opened
174 {
175 public:
176 std::string file_path;
177 /**
178 * @brief Constructor
179 *
180 * @param message A message to accompany the exception
181 * @param file_path The input file being processed
182 */
183 InvalidFile(std::string message, std::string file_path)
184 : ExceptionBase(message), file_path(file_path) { }
185 virtual ~InvalidFile() noexcept {}
186 };
187
188 /// Exception when no valid format is found for a file
190 {
191 public:
192 std::string file_path;
193 /**
194 * @brief Constructor
195 *
196 * @param message A message to accompany the exception
197 * @param file_path (optional) The input file being processed
198 */
199 InvalidFormat(std::string message, std::string file_path="")
200 : ExceptionBase(message), file_path(file_path) { }
201 virtual ~InvalidFormat() noexcept {}
202 };
203
204 /// Exception for invalid JSON
206 {
207 public:
208 std::string file_path;
209 /**
210 * @brief Constructor
211 *
212 * @param message A message to accompany the exception
213 * @param file_path (optional) The input file being processed
214 */
215 InvalidJSON(std::string message, std::string file_path="")
216 : ExceptionBase(message), file_path(file_path) { }
217 virtual ~InvalidJSON() noexcept {}
218 };
219
220 /// Exception when invalid encoding options are used
222 {
223 public:
224 std::string file_path;
225 /**
226 * @brief Constructor
227 *
228 * @param message A message to accompany the exception
229 * @param file_path (optional) The input file being processed
230 */
231 InvalidOptions(std::string message, std::string file_path="")
232 : ExceptionBase(message), file_path(file_path) { }
233 virtual ~InvalidOptions() noexcept {}
234 };
235
236 /// Exception when invalid sample rate is detected during encoding
238 {
239 public:
240 std::string file_path;
241 /**
242 * @brief Constructor
243 *
244 * @param message A message to accompany the exception
245 * @param file_path (optional) The input file being processed
246 */
247 InvalidSampleRate(std::string message, std::string file_path="")
248 : ExceptionBase(message), file_path(file_path) { }
249 virtual ~InvalidSampleRate() noexcept {}
250 };
251
252 /// Exception for missing JSON Change key
254 {
255 public:
256 std::string json;
257 /**
258 * @brief Constructor
259 *
260 * @param message A message to accompany the exception
261 * @param json The json data being processed
262 */
263 InvalidJSONKey(std::string message, std::string json)
264 : ExceptionBase(message), json(json) { }
265 virtual ~InvalidJSONKey() noexcept {}
266 };
267
268 /// Exception when no streams are found in the file
270 {
271 public:
272 std::string file_path;
273 /**
274 * @brief Constructor
275 *
276 * @param message A message to accompany the exception
277 * @param file_path (optional) The input file being processed
278 */
279 NoStreamsFound(std::string message, std::string file_path="")
280 : ExceptionBase(message), file_path(file_path) { }
281 virtual ~NoStreamsFound() noexcept {}
282 };
283
284 /// Exception for frames that are out of bounds.
286 {
287 public:
289 int64_t MaxFrames;
290 /**
291 * @brief Constructor
292 *
293 * @param message A message to accompany the exception
294 * @param frame_requested The out-of-bounds frame number requested
295 * @param max_frames The maximum available frame number
296 */
297 OutOfBoundsFrame(std::string message, int64_t frame_requested, int64_t max_frames)
298 : ExceptionBase(message), FrameRequested(frame_requested), MaxFrames(max_frames) { }
299 virtual ~OutOfBoundsFrame() noexcept {}
300 };
301
302 /// Exception for an out of bounds key-frame point.
304 {
305 public:
308 /**
309 * @brief Constructor
310 *
311 * @param message A message to accompany the exception
312 * @param point_requested The out-of-bounds point requested
313 * @param max_points The maximum available point value
314 */
315 OutOfBoundsPoint(std::string message, int point_requested, int max_points)
316 : ExceptionBase(message), PointRequested(point_requested), MaxPoints(max_points) { }
317 virtual ~OutOfBoundsPoint() noexcept {}
318 };
319
320 /// Exception when memory could not be allocated
322 {
323 public:
324 std::string file_path;
325 /**
326 * @brief Constructor
327 *
328 * @param message A message to accompany the exception
329 * @param file_path (optional) The input file being processed
330 */
331 OutOfMemory(std::string message, std::string file_path="")
332 : ExceptionBase(message), file_path(file_path) { }
333 virtual ~OutOfMemory() noexcept {}
334 };
335
336 /// Exception when a reader is closed, and a frame is requested
338 {
339 public:
340 std::string file_path;
341 /**
342 * @brief Constructor
343 *
344 * @param message A message to accompany the exception
345 * @param file_path (optional) The input file being processed
346 */
347 ReaderClosed(std::string message, std::string file_path="")
348 : ExceptionBase(message), file_path(file_path) { }
349 virtual ~ReaderClosed() noexcept {}
350 };
351
352 /// Exception when resample fails
354 {
355 public:
356 std::string file_path;
357 /**
358 * @brief Constructor
359 *
360 * @param message A message to accompany the exception
361 * @param file_path (optional) The input file being processed
362 */
363 ResampleError(std::string message, std::string file_path="")
364 : ExceptionBase(message), file_path(file_path) { }
365 virtual ~ResampleError() noexcept {}
366 };
367
368#define TMS_DEP_MSG "The library no longer throws this exception. It will be removed in a future release."
369
370#ifndef SWIG
371 /// Exception when too many seek attempts happen
372 class
373 __attribute__ ((deprecated(TMS_DEP_MSG)))
374 TooManySeeks : public ExceptionBase
375 {
376 public:
377 std::string file_path;
378 /**
379 * @brief Constructor
380 *
381 * @param message A message to accompany the exception
382 * @param file_path (optional) The input file being processed
383 */
384 TooManySeeks(std::string message, std::string file_path="") __attribute__ ((deprecated(TMS_DEP_MSG)));
385 virtual ~TooManySeeks() noexcept {}
386 };
387#endif
388
389 /// Exception when a writer is closed, and a frame is requested
391 {
392 public:
393 std::string file_path;
394 /**
395 * @brief Constructor
396 *
397 * @param message A message to accompany the exception
398 * @param file_path (optional) The output file being written
399 */
400 WriterClosed(std::string message, std::string file_path="")
401 : ExceptionBase(message), file_path(file_path) { }
402 virtual ~WriterClosed() noexcept {}
403 };
404}
405
406#endif
#define TMS_DEP_MSG
Definition: Exceptions.h:368
Exception when a required chunk is missing.
Definition: Exceptions.h:59
ChunkNotFound(std::string message, int64_t frame_number, int64_t chunk_number, int64_t chunk_frame)
Constructor.
Definition: Exceptions.h:72
virtual ~ChunkNotFound() noexcept
Definition: Exceptions.h:74
Exception when accessing a blackmagic decklink card.
Definition: Exceptions.h:80
DecklinkError(std::string message)
Constructor.
Definition: Exceptions.h:87
virtual ~DecklinkError() noexcept
Definition: Exceptions.h:89
Exception when decoding audio packet.
Definition: Exceptions.h:94
ErrorDecodingAudio(std::string message, int64_t frame_number)
Constructor.
Definition: Exceptions.h:103
virtual ~ErrorDecodingAudio() noexcept
Definition: Exceptions.h:105
Exception when encoding audio packet.
Definition: Exceptions.h:110
ErrorEncodingAudio(std::string message, int64_t frame_number)
Constructor.
Definition: Exceptions.h:119
virtual ~ErrorEncodingAudio() noexcept
Definition: Exceptions.h:121
Exception when encoding audio packet.
Definition: Exceptions.h:126
ErrorEncodingVideo(std::string message, int64_t frame_number)
Constructor.
Definition: Exceptions.h:135
virtual ~ErrorEncodingVideo() noexcept
Definition: Exceptions.h:137
Base exception class with a custom message variable.
Definition: Exceptions.h:45
virtual ~ExceptionBase() noexcept
Definition: Exceptions.h:50
std::string m_message
Definition: Exceptions.h:47
ExceptionBase(std::string message)
Definition: Exceptions.h:49
virtual const char * what() const noexcept
Definition: Exceptions.h:51
Exception when an invalid # of audio channels are detected.
Definition: Exceptions.h:142
InvalidChannels(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:151
virtual ~InvalidChannels() noexcept
Definition: Exceptions.h:153
Exception when no valid codec is found for a file.
Definition: Exceptions.h:158
InvalidCodec(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:167
std::string file_path
Definition: Exceptions.h:160
virtual ~InvalidCodec() noexcept
Definition: Exceptions.h:169
Exception for files that can not be found or opened.
Definition: Exceptions.h:174
std::string file_path
Definition: Exceptions.h:176
InvalidFile(std::string message, std::string file_path)
Constructor.
Definition: Exceptions.h:183
virtual ~InvalidFile() noexcept
Definition: Exceptions.h:185
Exception when no valid format is found for a file.
Definition: Exceptions.h:190
virtual ~InvalidFormat() noexcept
Definition: Exceptions.h:201
InvalidFormat(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:199
Exception for missing JSON Change key.
Definition: Exceptions.h:254
virtual ~InvalidJSONKey() noexcept
Definition: Exceptions.h:265
InvalidJSONKey(std::string message, std::string json)
Constructor.
Definition: Exceptions.h:263
Exception for invalid JSON.
Definition: Exceptions.h:206
virtual ~InvalidJSON() noexcept
Definition: Exceptions.h:217
std::string file_path
Definition: Exceptions.h:208
InvalidJSON(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:215
Exception when invalid encoding options are used.
Definition: Exceptions.h:222
InvalidOptions(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:231
virtual ~InvalidOptions() noexcept
Definition: Exceptions.h:233
Exception when invalid sample rate is detected during encoding.
Definition: Exceptions.h:238
virtual ~InvalidSampleRate() noexcept
Definition: Exceptions.h:249
InvalidSampleRate(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:247
Exception when no streams are found in the file.
Definition: Exceptions.h:270
NoStreamsFound(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:279
virtual ~NoStreamsFound() noexcept
Definition: Exceptions.h:281
Exception for frames that are out of bounds.
Definition: Exceptions.h:286
OutOfBoundsFrame(std::string message, int64_t frame_requested, int64_t max_frames)
Constructor.
Definition: Exceptions.h:297
virtual ~OutOfBoundsFrame() noexcept
Definition: Exceptions.h:299
Exception for an out of bounds key-frame point.
Definition: Exceptions.h:304
virtual ~OutOfBoundsPoint() noexcept
Definition: Exceptions.h:317
OutOfBoundsPoint(std::string message, int point_requested, int max_points)
Constructor.
Definition: Exceptions.h:315
Exception when memory could not be allocated.
Definition: Exceptions.h:322
virtual ~OutOfMemory() noexcept
Definition: Exceptions.h:333
std::string file_path
Definition: Exceptions.h:324
OutOfMemory(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:331
Exception when a reader is closed, and a frame is requested.
Definition: Exceptions.h:338
virtual ~ReaderClosed() noexcept
Definition: Exceptions.h:349
std::string file_path
Definition: Exceptions.h:340
ReaderClosed(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:347
Exception when resample fails.
Definition: Exceptions.h:354
virtual ~ResampleError() noexcept
Definition: Exceptions.h:365
ResampleError(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:363
Exception when too many seek attempts happen.
Definition: Exceptions.h:391
WriterClosed(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:400
virtual ~WriterClosed() noexcept
Definition: Exceptions.h:402
std::string file_path
Definition: Exceptions.h:393
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:47