OpenShot Library | libopenshot 0.3.3
Loading...
Searching...
No Matches
Exceptions.h
Go to the documentation of this file.
1
9// Copyright (c) 2008-2019 OpenShot Studios, LLC
10//
11// SPDX-License-Identifier: LGPL-3.0-or-later
12
13#ifndef OPENSHOT_EXCEPTIONS_H
14#define OPENSHOT_EXCEPTIONS_H
15
16#include <string>
17#include <cstring>
18
19namespace openshot {
20
27 class ExceptionBase : public std::exception
28 {
29 protected:
30 std::string m_message;
31 public:
32 ExceptionBase(std::string message) : m_message(message) { }
33 virtual ~ExceptionBase() noexcept {}
34 virtual const char* what() const noexcept {
35 // return custom message
36 return m_message.c_str();
37 }
38 virtual std::string py_message() const {
39 // return complete message for Python exception handling
40 return m_message;
41 }
42 };
43
45 {
46 public:
47 int64_t frame_number;
48 FrameExceptionBase(std::string message, int64_t frame_number=-1)
50 virtual std::string py_message() const override {
51 // return complete message for Python exception handling
52 std::string out_msg(m_message +
53 (frame_number > 0
54 ? " at frame " + std::to_string(frame_number)
55 : ""));
56 return out_msg;
57 }
58 };
59
60
62 {
63 public:
64 std::string file_path;
65 FileExceptionBase(std::string message, std::string file_path="")
66 : ExceptionBase(message), file_path(file_path) { }
67 virtual std::string py_message() const override {
68 // return complete message for Python exception handling
69 std::string out_msg(m_message +
70 (file_path != ""
71 ? " for file " + file_path
72 : ""));
73 return out_msg;
74 }
75 };
76
79 {
80 public:
81 int64_t chunk_number;
82 int64_t chunk_frame;
93 virtual ~ChunkNotFound() noexcept {}
94 };
95
96
99 {
100 public:
106 DecklinkError(std::string message)
107 : ExceptionBase(message) { }
108 virtual ~DecklinkError() noexcept {}
109 };
110
113 {
114 public:
121 ErrorDecodingAudio(std::string message, int64_t frame_number=-1)
122 : FrameExceptionBase(message, frame_number) { }
123 virtual ~ErrorDecodingAudio() noexcept {}
124 };
125
128 {
129 public:
136 ErrorEncodingAudio(std::string message, int64_t frame_number=-1)
137 : FrameExceptionBase(message, frame_number) { }
138 virtual ~ErrorEncodingAudio() noexcept {}
139 };
140
143 {
144 public:
151 ErrorEncodingVideo(std::string message, int64_t frame_number=-1)
152 : FrameExceptionBase(message, frame_number) { }
153 virtual ~ErrorEncodingVideo() noexcept {}
154 };
155
158 {
159 public:
166 InvalidChannels(std::string message, std::string file_path="")
167 : FileExceptionBase(message, file_path) { }
168 virtual ~InvalidChannels() noexcept {}
169 };
170
173 {
174 public:
181 InvalidCodec(std::string message, std::string file_path="")
182 : FileExceptionBase(message, file_path) { }
183 virtual ~InvalidCodec() noexcept {}
184 };
185
188 {
189 public:
196 InvalidFile(std::string message, std::string file_path)
197 : FileExceptionBase(message, file_path) { }
198 virtual ~InvalidFile() noexcept {}
199 };
200
203 {
204 public:
211 InvalidFormat(std::string message, std::string file_path="")
212 : FileExceptionBase(message, file_path) { }
213 virtual ~InvalidFormat() noexcept {}
214 };
215
218 {
219 public:
226 InvalidJSON(std::string message, std::string file_path="")
227 : FileExceptionBase(message, file_path) { }
228 virtual ~InvalidJSON() noexcept {}
229 };
230
233 {
234 public:
241 InvalidOptions(std::string message, std::string file_path="")
242 : FileExceptionBase(message, file_path) { }
243 virtual ~InvalidOptions() noexcept {}
244 };
245
248 {
249 public:
256 InvalidSampleRate(std::string message, std::string file_path="")
257 : FileExceptionBase(message, file_path) { }
258 virtual ~InvalidSampleRate() noexcept {}
259 };
260
263 {
264 public:
265 std::string json;
272 InvalidJSONKey(std::string message, std::string json)
273 : ExceptionBase(message), json(json) { }
274 virtual ~InvalidJSONKey() noexcept {}
275 std::string py_message() const override {
276 std::string out_msg = m_message +
277 " for JSON data " +
278 (json.size() > 100 ? " (abbreviated): " : ": ")
279 + json.substr(0, 99);
280 return out_msg;
281 }
282 };
283
286 {
287 public:
294 NoStreamsFound(std::string message, std::string file_path="")
295 : FileExceptionBase(message, file_path) { }
296 virtual ~NoStreamsFound() noexcept {}
297 };
298
301 {
302 public:
304 int64_t MaxFrames;
312 OutOfBoundsFrame(std::string message, int64_t frame_requested, int64_t max_frames)
313 : ExceptionBase(message), FrameRequested(frame_requested), MaxFrames(max_frames) { }
314 virtual ~OutOfBoundsFrame() noexcept {}
315 std::string py_message() const override {
316 std::string out_msg(m_message
317 + " Frame requested: " + std::to_string(FrameRequested)
318 + " Max frames: " + std::to_string(MaxFrames));
319 return out_msg;
320 }
321 };
322
325 {
326 public:
336 OutOfBoundsPoint(std::string message, int point_requested, int max_points)
337 : ExceptionBase(message), PointRequested(point_requested), MaxPoints(max_points) { }
338 virtual ~OutOfBoundsPoint() noexcept {}
339 std::string py_message() const override {
340 std::string out_msg(m_message
341 + " Point requested: " + std::to_string(PointRequested)
342 + " Max point: " + std::to_string(MaxPoints));
343 return out_msg;
344 }
345 };
346
349 {
350 public:
357 OutOfMemory(std::string message, std::string file_path="")
358 : FileExceptionBase(message, file_path) { }
359 virtual ~OutOfMemory() noexcept {}
360 };
361
364 {
365 public:
372 ReaderClosed(std::string message, std::string file_path="")
373 : FileExceptionBase(message, file_path) { }
374 virtual ~ReaderClosed() noexcept {}
375 };
376
379 {
380 public:
387 ResampleError(std::string message, std::string file_path="")
388 : FileExceptionBase(message, file_path) { }
389 virtual ~ResampleError() noexcept {}
390 };
391
392#define TMS_DEP_MSG "The library no longer throws this exception. It will be removed in a future release."
393
394#ifndef SWIG
396 class
397 [[deprecated(TMS_DEP_MSG)]]
399 {
400 public:
407 [[deprecated(TMS_DEP_MSG)]]
408 TooManySeeks(std::string message, std::string file_path="")
409 : FileExceptionBase(message, file_path) { }
410 virtual ~TooManySeeks() noexcept {}
411 };
412#endif
413
416 {
417 public:
424 WriterClosed(std::string message, std::string file_path="")
425 : FileExceptionBase(message, file_path) { }
426 virtual ~WriterClosed() noexcept {}
427 };
428}
429
430#endif
#define TMS_DEP_MSG
Definition Exceptions.h:392
Exception when a required chunk is missing.
Definition Exceptions.h:79
ChunkNotFound(std::string message, int64_t frame_number, int64_t chunk_number, int64_t chunk_frame)
Constructor.
Definition Exceptions.h:91
virtual ~ChunkNotFound() noexcept
Definition Exceptions.h:93
Exception when accessing a blackmagic decklink card.
Definition Exceptions.h:99
DecklinkError(std::string message)
Constructor.
Definition Exceptions.h:106
virtual ~DecklinkError() noexcept
Definition Exceptions.h:108
Exception when decoding audio packet.
Definition Exceptions.h:113
virtual ~ErrorDecodingAudio() noexcept
Definition Exceptions.h:123
ErrorDecodingAudio(std::string message, int64_t frame_number=-1)
Constructor.
Definition Exceptions.h:121
Exception when encoding audio packet.
Definition Exceptions.h:128
ErrorEncodingAudio(std::string message, int64_t frame_number=-1)
Constructor.
Definition Exceptions.h:136
virtual ~ErrorEncodingAudio() noexcept
Definition Exceptions.h:138
Exception when encoding audio packet.
Definition Exceptions.h:143
virtual ~ErrorEncodingVideo() noexcept
Definition Exceptions.h:153
ErrorEncodingVideo(std::string message, int64_t frame_number=-1)
Constructor.
Definition Exceptions.h:151
Base exception class with a custom message variable.
Definition Exceptions.h:28
virtual ~ExceptionBase() noexcept
Definition Exceptions.h:33
virtual std::string py_message() const
Definition Exceptions.h:38
ExceptionBase(std::string message)
Definition Exceptions.h:32
virtual const char * what() const noexcept
Definition Exceptions.h:34
FileExceptionBase(std::string message, std::string file_path="")
Definition Exceptions.h:65
virtual std::string py_message() const override
Definition Exceptions.h:67
FrameExceptionBase(std::string message, int64_t frame_number=-1)
Definition Exceptions.h:48
virtual std::string py_message() const override
Definition Exceptions.h:50
Exception when an invalid # of audio channels are detected.
Definition Exceptions.h:158
InvalidChannels(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:166
virtual ~InvalidChannels() noexcept
Definition Exceptions.h:168
Exception when no valid codec is found for a file.
Definition Exceptions.h:173
InvalidCodec(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:181
virtual ~InvalidCodec() noexcept
Definition Exceptions.h:183
Exception for files that can not be found or opened.
Definition Exceptions.h:188
InvalidFile(std::string message, std::string file_path)
Constructor.
Definition Exceptions.h:196
virtual ~InvalidFile() noexcept
Definition Exceptions.h:198
Exception when no valid format is found for a file.
Definition Exceptions.h:203
virtual ~InvalidFormat() noexcept
Definition Exceptions.h:213
InvalidFormat(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:211
Exception for missing JSON Change key.
Definition Exceptions.h:263
std::string py_message() const override
Definition Exceptions.h:275
virtual ~InvalidJSONKey() noexcept
Definition Exceptions.h:274
InvalidJSONKey(std::string message, std::string json)
Constructor.
Definition Exceptions.h:272
Exception for invalid JSON.
Definition Exceptions.h:218
virtual ~InvalidJSON() noexcept
Definition Exceptions.h:228
InvalidJSON(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:226
Exception when invalid encoding options are used.
Definition Exceptions.h:233
InvalidOptions(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:241
virtual ~InvalidOptions() noexcept
Definition Exceptions.h:243
Exception when invalid sample rate is detected during encoding.
Definition Exceptions.h:248
virtual ~InvalidSampleRate() noexcept
Definition Exceptions.h:258
InvalidSampleRate(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:256
Exception when no streams are found in the file.
Definition Exceptions.h:286
NoStreamsFound(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:294
virtual ~NoStreamsFound() noexcept
Definition Exceptions.h:296
Exception for frames that are out of bounds.
Definition Exceptions.h:301
OutOfBoundsFrame(std::string message, int64_t frame_requested, int64_t max_frames)
Constructor.
Definition Exceptions.h:312
virtual ~OutOfBoundsFrame() noexcept
Definition Exceptions.h:314
std::string py_message() const override
Definition Exceptions.h:315
Exception for an out of bounds key-frame point.
Definition Exceptions.h:325
std::string py_message() const override
Definition Exceptions.h:339
virtual ~OutOfBoundsPoint() noexcept
Definition Exceptions.h:338
OutOfBoundsPoint(std::string message, int point_requested, int max_points)
Constructor.
Definition Exceptions.h:336
Exception when memory could not be allocated.
Definition Exceptions.h:349
virtual ~OutOfMemory() noexcept
Definition Exceptions.h:359
OutOfMemory(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:357
Exception when a reader is closed, and a frame is requested.
Definition Exceptions.h:364
virtual ~ReaderClosed() noexcept
Definition Exceptions.h:374
ReaderClosed(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:372
Exception when resample fails.
Definition Exceptions.h:379
virtual ~ResampleError() noexcept
Definition Exceptions.h:389
ResampleError(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:387
Exception when too many seek attempts happen.
Definition Exceptions.h:399
virtual ~TooManySeeks() noexcept
Definition Exceptions.h:410
TooManySeeks(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:408
Exception when a writer is closed, and a frame is requested.
Definition Exceptions.h:416
WriterClosed(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:424
virtual ~WriterClosed() noexcept
Definition Exceptions.h:426
This namespace is the default namespace for all code in the openshot library.
Definition Compressor.h:29