Skip to content

Commit ca885d5

Browse files
authored
Merge pull request #315 from ferdnyc/exception-default-args
Exceptions: Make (most) file_path args optional
2 parents be24c58 + 462f0b7 commit ca885d5

36 files changed

+226
-97
lines changed

include/Exceptions.h

Lines changed: 141 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ namespace openshot {
6161
int64_t frame_number;
6262
int64_t chunk_number;
6363
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+
*/
6472
ChunkNotFound(std::string message, int64_t frame_number, int64_t chunk_number, int64_t chunk_frame)
6573
: BaseException(message), frame_number(frame_number), chunk_number(chunk_number), chunk_frame(chunk_frame) { }
6674
virtual ~ChunkNotFound() noexcept {}
@@ -71,6 +79,11 @@ namespace openshot {
7179
class DecklinkError : public BaseException
7280
{
7381
public:
82+
/**
83+
* @brief Constructor
84+
*
85+
* @param message A message to accompany the exception
86+
*/
7487
DecklinkError(std::string message)
7588
: BaseException(message) { }
7689
virtual ~DecklinkError() noexcept {}
@@ -81,6 +94,12 @@ namespace openshot {
8194
{
8295
public:
8396
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+
*/
84103
ErrorDecodingAudio(std::string message, int64_t frame_number)
85104
: BaseException(message), frame_number(frame_number) { }
86105
virtual ~ErrorDecodingAudio() noexcept {}
@@ -91,6 +110,12 @@ namespace openshot {
91110
{
92111
public:
93112
int64_t frame_number;
113+
/**
114+
* @brief Constructor
115+
*
116+
* @param message A message to accompany the exception
117+
* @param frame_number The frame number being processed
118+
*/
94119
ErrorEncodingAudio(std::string message, int64_t frame_number)
95120
: BaseException(message), frame_number(frame_number) { }
96121
virtual ~ErrorEncodingAudio() noexcept {}
@@ -101,6 +126,12 @@ namespace openshot {
101126
{
102127
public:
103128
int64_t frame_number;
129+
/**
130+
* @brief Constructor
131+
*
132+
* @param message A message to accompany the exception
133+
* @param frame_number The frame number being processed
134+
*/
104135
ErrorEncodingVideo(std::string message, int64_t frame_number)
105136
: BaseException(message), frame_number(frame_number) { }
106137
virtual ~ErrorEncodingVideo() noexcept {}
@@ -111,7 +142,13 @@ namespace openshot {
111142
{
112143
public:
113144
std::string file_path;
114-
InvalidChannels(std::string message, 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="")
115152
: BaseException(message), file_path(file_path) { }
116153
virtual ~InvalidChannels() noexcept {}
117154
};
@@ -121,7 +158,13 @@ namespace openshot {
121158
{
122159
public:
123160
std::string file_path;
124-
InvalidCodec(std::string message, 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="")
125168
: BaseException(message), file_path(file_path) { }
126169
virtual ~InvalidCodec() noexcept {}
127170
};
@@ -131,6 +174,12 @@ namespace openshot {
131174
{
132175
public:
133176
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+
*/
134183
InvalidFile(std::string message, std::string file_path)
135184
: BaseException(message), file_path(file_path) { }
136185
virtual ~InvalidFile() noexcept {}
@@ -141,7 +190,13 @@ namespace openshot {
141190
{
142191
public:
143192
std::string file_path;
144-
InvalidFormat(std::string message, 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="")
145200
: BaseException(message), file_path(file_path) { }
146201
virtual ~InvalidFormat() noexcept {}
147202
};
@@ -151,7 +206,13 @@ namespace openshot {
151206
{
152207
public:
153208
std::string file_path;
154-
InvalidJSON(std::string message, 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="")
155216
: BaseException(message), file_path(file_path) { }
156217
virtual ~InvalidJSON() noexcept {}
157218
};
@@ -161,7 +222,13 @@ namespace openshot {
161222
{
162223
public:
163224
std::string file_path;
164-
InvalidOptions(std::string message, 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="")
165232
: BaseException(message), file_path(file_path) { }
166233
virtual ~InvalidOptions() noexcept {}
167234
};
@@ -171,7 +238,13 @@ namespace openshot {
171238
{
172239
public:
173240
std::string file_path;
174-
InvalidSampleRate(std::string message, 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="")
175248
: BaseException(message), file_path(file_path) { }
176249
virtual ~InvalidSampleRate() noexcept {}
177250
};
@@ -181,6 +254,12 @@ namespace openshot {
181254
{
182255
public:
183256
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+
*/
184263
InvalidJSONKey(std::string message, std::string json)
185264
: BaseException(message), json(json) { }
186265
virtual ~InvalidJSONKey() noexcept {}
@@ -191,7 +270,13 @@ namespace openshot {
191270
{
192271
public:
193272
std::string file_path;
194-
NoStreamsFound(std::string message, 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="")
195280
: BaseException(message), file_path(file_path) { }
196281
virtual ~NoStreamsFound() noexcept {}
197282
};
@@ -202,6 +287,13 @@ namespace openshot {
202287
public:
203288
int64_t FrameRequested;
204289
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+
*/
205297
OutOfBoundsFrame(std::string message, int64_t frame_requested, int64_t max_frames)
206298
: BaseException(message), FrameRequested(frame_requested), MaxFrames(max_frames) { }
207299
virtual ~OutOfBoundsFrame() noexcept {}
@@ -213,6 +305,13 @@ namespace openshot {
213305
public:
214306
int PointRequested;
215307
int MaxPoints;
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+
*/
216315
OutOfBoundsPoint(std::string message, int point_requested, int max_points)
217316
: BaseException(message), PointRequested(point_requested), MaxPoints(max_points) { }
218317
virtual ~OutOfBoundsPoint() noexcept {}
@@ -223,7 +322,13 @@ namespace openshot {
223322
{
224323
public:
225324
std::string file_path;
226-
OutOfMemory(std::string message, 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="")
227332
: BaseException(message), file_path(file_path) { }
228333
virtual ~OutOfMemory() noexcept {}
229334
};
@@ -233,7 +338,13 @@ namespace openshot {
233338
{
234339
public:
235340
std::string file_path;
236-
ReaderClosed(std::string message, 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="")
237348
: BaseException(message), file_path(file_path) { }
238349
virtual ~ReaderClosed() noexcept {}
239350
};
@@ -243,7 +354,13 @@ namespace openshot {
243354
{
244355
public:
245356
std::string file_path;
246-
ResampleError(std::string message, 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="")
247364
: BaseException(message), file_path(file_path) { }
248365
virtual ~ResampleError() noexcept {}
249366
};
@@ -253,7 +370,13 @@ namespace openshot {
253370
{
254371
public:
255372
std::string file_path;
256-
TooManySeeks(std::string message, std::string file_path)
373+
/**
374+
* @brief Constructor
375+
*
376+
* @param message A message to accompany the exception
377+
* @param file_path (optional) The input file being processed
378+
*/
379+
TooManySeeks(std::string message, std::string file_path="")
257380
: BaseException(message), file_path(file_path) { }
258381
virtual ~TooManySeeks() noexcept {}
259382
};
@@ -263,7 +386,13 @@ namespace openshot {
263386
{
264387
public:
265388
std::string file_path;
266-
WriterClosed(std::string message, std::string file_path)
389+
/**
390+
* @brief Constructor
391+
*
392+
* @param message A message to accompany the exception
393+
* @param file_path (optional) The output file being written
394+
*/
395+
WriterClosed(std::string message, std::string file_path="")
267396
: BaseException(message), file_path(file_path) { }
268397
virtual ~WriterClosed() noexcept {}
269398
};

src/CacheDisk.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ void CacheDisk::SetJson(string value) {
519519

520520
if (!success)
521521
// Raise exception
522-
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
522+
throw InvalidJSON("JSON could not be parsed (or is invalid)");
523523

524524
try
525525
{
@@ -529,7 +529,7 @@ void CacheDisk::SetJson(string value) {
529529
catch (const std::exception& e)
530530
{
531531
// Error parsing JSON (or missing keys)
532-
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", "");
532+
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)");
533533
}
534534
}
535535

src/CacheMemory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ void CacheMemory::SetJson(string value) {
372372
delete reader;
373373
if (!success)
374374
// Raise exception
375-
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
375+
throw InvalidJSON("JSON could not be parsed (or is invalid)");
376376

377377
try
378378
{
@@ -382,7 +382,7 @@ void CacheMemory::SetJson(string value) {
382382
catch (const std::exception& e)
383383
{
384384
// Error parsing JSON (or missing keys)
385-
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", "");
385+
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)");
386386
}
387387
}
388388

src/ChunkReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ void ChunkReader::SetJson(string value) {
292292
delete reader;
293293
if (!success)
294294
// Raise exception
295-
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
295+
throw InvalidJSON("JSON could not be parsed (or is invalid)");
296296

297297
try
298298
{
@@ -302,7 +302,7 @@ void ChunkReader::SetJson(string value) {
302302
catch (const std::exception& e)
303303
{
304304
// Error parsing JSON (or missing keys)
305-
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", "");
305+
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)");
306306
}
307307
}
308308

0 commit comments

Comments
 (0)