Skip to content

Commit f36bb33

Browse files
authored
Exceptions: Rename BaseException, for python (#497)
BaseException is a python standard library exception class, so it's not a great idea to redefine that name in our bindings. Renamed to ExceptionBase, which is more in keeping with our class naming system anyway.
1 parent 6353c3b commit f36bb33

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

include/Exceptions.h

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,24 @@ namespace openshot {
3838
/**
3939
* @brief Base exception class with a custom message variable.
4040
*
41-
* A custom error message field has been added to the std::exception base class. All
42-
* OpenShot exception classes inherit from this class.
41+
* A std::exception-derived exception class with custom message.
42+
* All OpenShot exception classes inherit from this class.
4343
*/
44-
class BaseException : public std::exception //: public exception
44+
class ExceptionBase : public std::exception //: public exception
4545
{
4646
protected:
4747
std::string m_message;
4848
public:
49-
BaseException(std::string message) : m_message(message) { }
50-
virtual ~BaseException() noexcept {}
49+
ExceptionBase(std::string message) : m_message(message) { }
50+
virtual ~ExceptionBase() noexcept {}
5151
virtual const char* what() const noexcept {
5252
// return custom message
5353
return m_message.c_str();
5454
}
5555
};
5656

5757
/// Exception when a required chunk is missing
58-
class ChunkNotFound : public BaseException
58+
class ChunkNotFound : public ExceptionBase
5959
{
6060
public:
6161
int64_t frame_number;
@@ -70,13 +70,13 @@ namespace openshot {
7070
* @param chunk_frame The chunk frame
7171
*/
7272
ChunkNotFound(std::string message, int64_t frame_number, int64_t chunk_number, int64_t chunk_frame)
73-
: BaseException(message), frame_number(frame_number), chunk_number(chunk_number), chunk_frame(chunk_frame) { }
73+
: ExceptionBase(message), frame_number(frame_number), chunk_number(chunk_number), chunk_frame(chunk_frame) { }
7474
virtual ~ChunkNotFound() noexcept {}
7575
};
7676

7777

7878
/// Exception when accessing a blackmagic decklink card
79-
class DecklinkError : public BaseException
79+
class DecklinkError : public ExceptionBase
8080
{
8181
public:
8282
/**
@@ -85,12 +85,12 @@ namespace openshot {
8585
* @param message A message to accompany the exception
8686
*/
8787
DecklinkError(std::string message)
88-
: BaseException(message) { }
88+
: ExceptionBase(message) { }
8989
virtual ~DecklinkError() noexcept {}
9090
};
9191

9292
/// Exception when decoding audio packet
93-
class ErrorDecodingAudio : public BaseException
93+
class ErrorDecodingAudio : public ExceptionBase
9494
{
9595
public:
9696
int64_t frame_number;
@@ -101,12 +101,12 @@ namespace openshot {
101101
* @param frame_number The frame number being processed
102102
*/
103103
ErrorDecodingAudio(std::string message, int64_t frame_number)
104-
: BaseException(message), frame_number(frame_number) { }
104+
: ExceptionBase(message), frame_number(frame_number) { }
105105
virtual ~ErrorDecodingAudio() noexcept {}
106106
};
107107

108108
/// Exception when encoding audio packet
109-
class ErrorEncodingAudio : public BaseException
109+
class ErrorEncodingAudio : public ExceptionBase
110110
{
111111
public:
112112
int64_t frame_number;
@@ -117,12 +117,12 @@ namespace openshot {
117117
* @param frame_number The frame number being processed
118118
*/
119119
ErrorEncodingAudio(std::string message, int64_t frame_number)
120-
: BaseException(message), frame_number(frame_number) { }
120+
: ExceptionBase(message), frame_number(frame_number) { }
121121
virtual ~ErrorEncodingAudio() noexcept {}
122122
};
123123

124124
/// Exception when encoding audio packet
125-
class ErrorEncodingVideo : public BaseException
125+
class ErrorEncodingVideo : public ExceptionBase
126126
{
127127
public:
128128
int64_t frame_number;
@@ -133,12 +133,12 @@ namespace openshot {
133133
* @param frame_number The frame number being processed
134134
*/
135135
ErrorEncodingVideo(std::string message, int64_t frame_number)
136-
: BaseException(message), frame_number(frame_number) { }
136+
: ExceptionBase(message), frame_number(frame_number) { }
137137
virtual ~ErrorEncodingVideo() noexcept {}
138138
};
139139

140140
/// Exception when an invalid # of audio channels are detected
141-
class InvalidChannels : public BaseException
141+
class InvalidChannels : public ExceptionBase
142142
{
143143
public:
144144
std::string file_path;
@@ -149,12 +149,12 @@ namespace openshot {
149149
* @param file_path (optional) The input file being processed
150150
*/
151151
InvalidChannels(std::string message, std::string file_path="")
152-
: BaseException(message), file_path(file_path) { }
152+
: ExceptionBase(message), file_path(file_path) { }
153153
virtual ~InvalidChannels() noexcept {}
154154
};
155155

156156
/// Exception when no valid codec is found for a file
157-
class InvalidCodec : public BaseException
157+
class InvalidCodec : public ExceptionBase
158158
{
159159
public:
160160
std::string file_path;
@@ -165,12 +165,12 @@ namespace openshot {
165165
* @param file_path (optional) The input file being processed
166166
*/
167167
InvalidCodec(std::string message, std::string file_path="")
168-
: BaseException(message), file_path(file_path) { }
168+
: ExceptionBase(message), file_path(file_path) { }
169169
virtual ~InvalidCodec() noexcept {}
170170
};
171171

172172
/// Exception for files that can not be found or opened
173-
class InvalidFile : public BaseException
173+
class InvalidFile : public ExceptionBase
174174
{
175175
public:
176176
std::string file_path;
@@ -181,12 +181,12 @@ namespace openshot {
181181
* @param file_path The input file being processed
182182
*/
183183
InvalidFile(std::string message, std::string file_path)
184-
: BaseException(message), file_path(file_path) { }
184+
: ExceptionBase(message), file_path(file_path) { }
185185
virtual ~InvalidFile() noexcept {}
186186
};
187187

188188
/// Exception when no valid format is found for a file
189-
class InvalidFormat : public BaseException
189+
class InvalidFormat : public ExceptionBase
190190
{
191191
public:
192192
std::string file_path;
@@ -197,12 +197,12 @@ namespace openshot {
197197
* @param file_path (optional) The input file being processed
198198
*/
199199
InvalidFormat(std::string message, std::string file_path="")
200-
: BaseException(message), file_path(file_path) { }
200+
: ExceptionBase(message), file_path(file_path) { }
201201
virtual ~InvalidFormat() noexcept {}
202202
};
203203

204204
/// Exception for invalid JSON
205-
class InvalidJSON : public BaseException
205+
class InvalidJSON : public ExceptionBase
206206
{
207207
public:
208208
std::string file_path;
@@ -213,12 +213,12 @@ namespace openshot {
213213
* @param file_path (optional) The input file being processed
214214
*/
215215
InvalidJSON(std::string message, std::string file_path="")
216-
: BaseException(message), file_path(file_path) { }
216+
: ExceptionBase(message), file_path(file_path) { }
217217
virtual ~InvalidJSON() noexcept {}
218218
};
219219

220220
/// Exception when invalid encoding options are used
221-
class InvalidOptions : public BaseException
221+
class InvalidOptions : public ExceptionBase
222222
{
223223
public:
224224
std::string file_path;
@@ -229,12 +229,12 @@ namespace openshot {
229229
* @param file_path (optional) The input file being processed
230230
*/
231231
InvalidOptions(std::string message, std::string file_path="")
232-
: BaseException(message), file_path(file_path) { }
232+
: ExceptionBase(message), file_path(file_path) { }
233233
virtual ~InvalidOptions() noexcept {}
234234
};
235235

236236
/// Exception when invalid sample rate is detected during encoding
237-
class InvalidSampleRate : public BaseException
237+
class InvalidSampleRate : public ExceptionBase
238238
{
239239
public:
240240
std::string file_path;
@@ -245,12 +245,12 @@ namespace openshot {
245245
* @param file_path (optional) The input file being processed
246246
*/
247247
InvalidSampleRate(std::string message, std::string file_path="")
248-
: BaseException(message), file_path(file_path) { }
248+
: ExceptionBase(message), file_path(file_path) { }
249249
virtual ~InvalidSampleRate() noexcept {}
250250
};
251251

252252
/// Exception for missing JSON Change key
253-
class InvalidJSONKey : public BaseException
253+
class InvalidJSONKey : public ExceptionBase
254254
{
255255
public:
256256
std::string json;
@@ -261,12 +261,12 @@ namespace openshot {
261261
* @param json The json data being processed
262262
*/
263263
InvalidJSONKey(std::string message, std::string json)
264-
: BaseException(message), json(json) { }
264+
: ExceptionBase(message), json(json) { }
265265
virtual ~InvalidJSONKey() noexcept {}
266266
};
267267

268268
/// Exception when no streams are found in the file
269-
class NoStreamsFound : public BaseException
269+
class NoStreamsFound : public ExceptionBase
270270
{
271271
public:
272272
std::string file_path;
@@ -277,12 +277,12 @@ namespace openshot {
277277
* @param file_path (optional) The input file being processed
278278
*/
279279
NoStreamsFound(std::string message, std::string file_path="")
280-
: BaseException(message), file_path(file_path) { }
280+
: ExceptionBase(message), file_path(file_path) { }
281281
virtual ~NoStreamsFound() noexcept {}
282282
};
283283

284284
/// Exception for frames that are out of bounds.
285-
class OutOfBoundsFrame : public BaseException
285+
class OutOfBoundsFrame : public ExceptionBase
286286
{
287287
public:
288288
int64_t FrameRequested;
@@ -295,12 +295,12 @@ namespace openshot {
295295
* @param max_frames The maximum available frame number
296296
*/
297297
OutOfBoundsFrame(std::string message, int64_t frame_requested, int64_t max_frames)
298-
: BaseException(message), FrameRequested(frame_requested), MaxFrames(max_frames) { }
298+
: ExceptionBase(message), FrameRequested(frame_requested), MaxFrames(max_frames) { }
299299
virtual ~OutOfBoundsFrame() noexcept {}
300300
};
301301

302302
/// Exception for an out of bounds key-frame point.
303-
class OutOfBoundsPoint : public BaseException
303+
class OutOfBoundsPoint : public ExceptionBase
304304
{
305305
public:
306306
int PointRequested;
@@ -313,12 +313,12 @@ namespace openshot {
313313
* @param max_points The maximum available point value
314314
*/
315315
OutOfBoundsPoint(std::string message, int point_requested, int max_points)
316-
: BaseException(message), PointRequested(point_requested), MaxPoints(max_points) { }
316+
: ExceptionBase(message), PointRequested(point_requested), MaxPoints(max_points) { }
317317
virtual ~OutOfBoundsPoint() noexcept {}
318318
};
319319

320320
/// Exception when memory could not be allocated
321-
class OutOfMemory : public BaseException
321+
class OutOfMemory : public ExceptionBase
322322
{
323323
public:
324324
std::string file_path;
@@ -329,12 +329,12 @@ namespace openshot {
329329
* @param file_path (optional) The input file being processed
330330
*/
331331
OutOfMemory(std::string message, std::string file_path="")
332-
: BaseException(message), file_path(file_path) { }
332+
: ExceptionBase(message), file_path(file_path) { }
333333
virtual ~OutOfMemory() noexcept {}
334334
};
335335

336336
/// Exception when a reader is closed, and a frame is requested
337-
class ReaderClosed : public BaseException
337+
class ReaderClosed : public ExceptionBase
338338
{
339339
public:
340340
std::string file_path;
@@ -345,12 +345,12 @@ namespace openshot {
345345
* @param file_path (optional) The input file being processed
346346
*/
347347
ReaderClosed(std::string message, std::string file_path="")
348-
: BaseException(message), file_path(file_path) { }
348+
: ExceptionBase(message), file_path(file_path) { }
349349
virtual ~ReaderClosed() noexcept {}
350350
};
351351

352352
/// Exception when resample fails
353-
class ResampleError : public BaseException
353+
class ResampleError : public ExceptionBase
354354
{
355355
public:
356356
std::string file_path;
@@ -361,12 +361,12 @@ namespace openshot {
361361
* @param file_path (optional) The input file being processed
362362
*/
363363
ResampleError(std::string message, std::string file_path="")
364-
: BaseException(message), file_path(file_path) { }
364+
: ExceptionBase(message), file_path(file_path) { }
365365
virtual ~ResampleError() noexcept {}
366366
};
367367

368368
/// Exception when too many seek attempts happen
369-
class TooManySeeks : public BaseException
369+
class TooManySeeks : public ExceptionBase
370370
{
371371
public:
372372
std::string file_path;
@@ -377,12 +377,12 @@ namespace openshot {
377377
* @param file_path (optional) The input file being processed
378378
*/
379379
TooManySeeks(std::string message, std::string file_path="")
380-
: BaseException(message), file_path(file_path) { }
380+
: ExceptionBase(message), file_path(file_path) { }
381381
virtual ~TooManySeeks() noexcept {}
382382
};
383383

384384
/// Exception when a writer is closed, and a frame is requested
385-
class WriterClosed : public BaseException
385+
class WriterClosed : public ExceptionBase
386386
{
387387
public:
388388
std::string file_path;
@@ -393,7 +393,7 @@ namespace openshot {
393393
* @param file_path (optional) The output file being written
394394
*/
395395
WriterClosed(std::string message, std::string file_path="")
396-
: BaseException(message), file_path(file_path) { }
396+
: ExceptionBase(message), file_path(file_path) { }
397397
virtual ~WriterClosed() noexcept {}
398398
};
399399
}

0 commit comments

Comments
 (0)