OpenShot Library | libopenshot  0.1.9
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  * @section LICENSE
7  *
8  * Copyright (c) 2008-2014 OpenShot Studios, LLC
9  * <http://www.openshotstudios.com/>. This file is part of
10  * OpenShot Library (libopenshot), an open-source project dedicated to
11  * delivering high quality video editing and animation solutions to the
12  * world. For more information visit <http://www.openshot.org/>.
13  *
14  * OpenShot Library (libopenshot) is free software: you can redistribute it
15  * and/or modify it under the terms of the GNU Lesser General Public License
16  * as published by the Free Software Foundation, either version 3 of the
17  * License, or (at your option) any later version.
18  *
19  * OpenShot Library (libopenshot) is distributed in the hope that it will be
20  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public License
25  * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
26  */
27 
28 #ifndef OPENSHOT_EXCEPTIONS_H
29 #define OPENSHOT_EXCEPTIONS_H
30 
31 #include <string>
32 using namespace std;
33 
34 namespace openshot {
35 
36  /**
37  * @brief Base exception class with a custom message variable.
38  *
39  * A custom error message field has been added to the std::exception base class. All
40  * OpenShot exception classes inherit from this class.
41  */
42  class BaseException : public std::exception //: public exception
43  {
44  protected:
45  string m_message;
46  public:
47  BaseException(string message) : m_message(message) { }
48  virtual ~BaseException() throw () {}
49  virtual const char* what() const throw () {
50  // return custom message
51  return m_message.c_str();
52  }
53  };
54 
55  /// Exception when a required chunk is missing
57  {
58  public:
59  string file_path;
60  int64_t frame_number;
61  int64_t chunk_number;
62  int64_t chunk_frame;
63  ChunkNotFound(string message, int64_t frame_number, int64_t chunk_number, int64_t chunk_frame)
64  : BaseException(message), frame_number(frame_number), chunk_number(chunk_number), chunk_frame(chunk_frame) { }
65  virtual ~ChunkNotFound() throw () {}
66  };
67 
68 
69  /// Exception when accessing a blackmagic decklink card
71  {
72  public:
73  DecklinkError(string message)
74  : BaseException(message) { }
75  virtual ~DecklinkError() throw () {}
76  };
77 
78  /// Exception when decoding audio packet
80  {
81  public:
82  string file_path;
83  int64_t frame_number;
84  ErrorDecodingAudio(string message, int64_t frame_number)
85  : BaseException(message), frame_number(frame_number) { }
86  virtual ~ErrorDecodingAudio() throw () {}
87  };
88 
89  /// Exception when encoding audio packet
91  {
92  public:
93  string file_path;
94  int64_t frame_number;
95  ErrorEncodingAudio(string message, int64_t frame_number)
96  : BaseException(message), frame_number(frame_number) { }
97  virtual ~ErrorEncodingAudio() throw () {}
98  };
99 
100  /// Exception when encoding audio packet
102  {
103  public:
104  string file_path;
105  int64_t frame_number;
106  ErrorEncodingVideo(string message, int64_t frame_number)
107  : BaseException(message), frame_number(frame_number) { }
108  virtual ~ErrorEncodingVideo() throw () {}
109  };
110 
111  /// Exception when an invalid # of audio channels are detected
113  {
114  public:
115  string file_path;
116  InvalidChannels(string message, string file_path)
117  : BaseException(message), file_path(file_path) { }
118  virtual ~InvalidChannels() throw () {}
119  };
120 
121  /// Exception when no valid codec is found for a file
123  {
124  public:
125  string file_path;
126  InvalidCodec(string message, string file_path)
127  : BaseException(message), file_path(file_path) { }
128  virtual ~InvalidCodec() throw () {}
129  };
130 
131  /// Exception for files that can not be found or opened
132  class InvalidFile : public BaseException
133  {
134  public:
135  string file_path;
136  InvalidFile(string message, string file_path)
137  : BaseException(message), file_path(file_path) { }
138  virtual ~InvalidFile() throw () {}
139  };
140 
141  /// Exception when no valid format is found for a file
143  {
144  public:
145  string file_path;
146  InvalidFormat(string message, string file_path)
147  : BaseException(message), file_path(file_path) { }
148  virtual ~InvalidFormat() throw () {}
149  };
150 
151  /// Exception for invalid JSON
152  class InvalidJSON : public BaseException
153  {
154  public:
155  string file_path;
156  InvalidJSON(string message, string file_path)
157  : BaseException(message), file_path(file_path) { }
158  virtual ~InvalidJSON() throw () {}
159  };
160 
161  /// Exception when invalid encoding options are used
163  {
164  public:
165  string file_path;
166  InvalidOptions(string message, string file_path)
167  : BaseException(message), file_path(file_path) { }
168  virtual ~InvalidOptions() throw () {}
169  };
170 
171  /// Exception when invalid sample rate is detected during encoding
173  {
174  public:
175  string file_path;
176  InvalidSampleRate(string message, string file_path)
177  : BaseException(message), file_path(file_path) { }
178  virtual ~InvalidSampleRate() throw () {}
179  };
180 
181  /// Exception for missing JSON Change key
183  {
184  public:
185  string json;
186  InvalidJSONKey(string message, string json)
187  : BaseException(message), json(json) { }
188  virtual ~InvalidJSONKey() throw () {}
189  };
190 
191  /// Exception when no streams are found in the file
193  {
194  public:
195  string file_path;
196  NoStreamsFound(string message, string file_path)
197  : BaseException(message), file_path(file_path) { }
198  virtual ~NoStreamsFound() throw () {}
199  };
200 
201  /// Exception for frames that are out of bounds.
203  {
204  public:
205  int64_t FrameRequested;
206  int64_t MaxFrames;
207  OutOfBoundsFrame(string message, int64_t frame_requested, int64_t max_frames)
208  : BaseException(message), FrameRequested(frame_requested), MaxFrames(max_frames) { }
209  virtual ~OutOfBoundsFrame() throw () {}
210  };
211 
212  /// Exception for an out of bounds key-frame point.
214  {
215  public:
218  OutOfBoundsPoint(string message, int point_requested, int max_points)
219  : BaseException(message), PointRequested(point_requested), MaxPoints(max_points) { }
220  virtual ~OutOfBoundsPoint() throw () {}
221  };
222 
223  /// Exception when memory could not be allocated
224  class OutOfMemory : public BaseException
225  {
226  public:
227  string file_path;
228  OutOfMemory(string message, string file_path)
229  : BaseException(message), file_path(file_path) { }
230  virtual ~OutOfMemory() throw () {}
231  };
232 
233  /// Exception when a reader is closed, and a frame is requested
235  {
236  public:
237  string file_path;
238  ReaderClosed(string message, string file_path)
239  : BaseException(message), file_path(file_path) { }
240  virtual ~ReaderClosed() throw () {}
241  };
242 
243  /// Exception when resample fails
245  {
246  public:
247  string file_path;
248  ResampleError(string message, string file_path)
249  : BaseException(message), file_path(file_path) { }
250  virtual ~ResampleError() throw () {}
251  };
252 
253  /// Exception when too many seek attempts happen
255  {
256  public:
257  string file_path;
258  TooManySeeks(string message, string file_path)
259  : BaseException(message), file_path(file_path) { }
260  virtual ~TooManySeeks() throw () {}
261  };
262 
263  /// Exception when a writer is closed, and a frame is requested
265  {
266  public:
267  string file_path;
268  WriterClosed(string message, string file_path)
269  : BaseException(message), file_path(file_path) { }
270  virtual ~WriterClosed() throw () {}
271  };
272 }
273 
274 #endif
virtual ~BaseException()
Definition: Exceptions.h:48
Exception when a required chunk is missing.
Definition: Exceptions.h:56
Exception when an invalid # of audio channels are detected.
Definition: Exceptions.h:112
Base exception class with a custom message variable.
Definition: Exceptions.h:42
virtual ~InvalidFile()
Definition: Exceptions.h:138
virtual ~ChunkNotFound()
Definition: Exceptions.h:65
Exception when encoding audio packet.
Definition: Exceptions.h:90
TooManySeeks(string message, string file_path)
Definition: Exceptions.h:258
virtual ~DecklinkError()
Definition: Exceptions.h:75
ResampleError(string message, string file_path)
Definition: Exceptions.h:248
Exception when a reader is closed, and a frame is requested.
Definition: Exceptions.h:234
InvalidChannels(string message, string file_path)
Definition: Exceptions.h:116
InvalidSampleRate(string message, string file_path)
Definition: Exceptions.h:176
BaseException(string message)
Definition: Exceptions.h:47
Exception when encoding audio packet.
Definition: Exceptions.h:101
Exception when invalid sample rate is detected during encoding.
Definition: Exceptions.h:172
virtual ~OutOfMemory()
Definition: Exceptions.h:230
Exception for missing JSON Change key.
Definition: Exceptions.h:182
Exception when no valid codec is found for a file.
Definition: Exceptions.h:122
Exception when memory could not be allocated.
Definition: Exceptions.h:224
Exception when invalid encoding options are used.
Definition: Exceptions.h:162
Exception when accessing a blackmagic decklink card.
Definition: Exceptions.h:70
Exception when no streams are found in the file.
Definition: Exceptions.h:192
ReaderClosed(string message, string file_path)
Definition: Exceptions.h:238
Exception for files that can not be found or opened.
Definition: Exceptions.h:132
ErrorEncodingAudio(string message, int64_t frame_number)
Definition: Exceptions.h:95
InvalidJSON(string message, string file_path)
Definition: Exceptions.h:156
DecklinkError(string message)
Definition: Exceptions.h:73
OutOfMemory(string message, string file_path)
Definition: Exceptions.h:228
InvalidJSONKey(string message, string json)
Definition: Exceptions.h:186
WriterClosed(string message, string file_path)
Definition: Exceptions.h:268
InvalidFile(string message, string file_path)
Definition: Exceptions.h:136
Exception for frames that are out of bounds.
Definition: Exceptions.h:202
NoStreamsFound(string message, string file_path)
Definition: Exceptions.h:196
This namespace is the default namespace for all code in the openshot library.
Exception for invalid JSON.
Definition: Exceptions.h:152
InvalidFormat(string message, string file_path)
Definition: Exceptions.h:146
virtual const char * what() const
Definition: Exceptions.h:49
Exception for an out of bounds key-frame point.
Definition: Exceptions.h:213
ChunkNotFound(string message, int64_t frame_number, int64_t chunk_number, int64_t chunk_frame)
Definition: Exceptions.h:63
OutOfBoundsPoint(string message, int point_requested, int max_points)
Definition: Exceptions.h:218
ErrorEncodingVideo(string message, int64_t frame_number)
Definition: Exceptions.h:106
virtual ~InvalidJSON()
Definition: Exceptions.h:158
InvalidCodec(string message, string file_path)
Definition: Exceptions.h:126
Exception when decoding audio packet.
Definition: Exceptions.h:79
ErrorDecodingAudio(string message, int64_t frame_number)
Definition: Exceptions.h:84
InvalidOptions(string message, string file_path)
Definition: Exceptions.h:166
Exception when a writer is closed, and a frame is requested.
Definition: Exceptions.h:264
OutOfBoundsFrame(string message, int64_t frame_requested, int64_t max_frames)
Definition: Exceptions.h:207
Exception when no valid format is found for a file.
Definition: Exceptions.h:142
Exception when resample fails.
Definition: Exceptions.h:244
Exception when too many seek attempts happen.
Definition: Exceptions.h:254