OpenShot Library | libopenshot  0.2.2
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
openshot::InvalidFormat
Exception when no valid format is found for a file.
Definition: Exceptions.h:142
openshot::InvalidSampleRate
Exception when invalid sample rate is detected during encoding.
Definition: Exceptions.h:172
openshot::ErrorDecodingAudio::ErrorDecodingAudio
ErrorDecodingAudio(string message, int64_t frame_number)
Definition: Exceptions.h:84
openshot::ReaderClosed::file_path
string file_path
Definition: Exceptions.h:237
openshot::ChunkNotFound::file_path
string file_path
Definition: Exceptions.h:59
openshot::InvalidCodec
Exception when no valid codec is found for a file.
Definition: Exceptions.h:122
openshot::InvalidChannels::file_path
string file_path
Definition: Exceptions.h:115
openshot::WriterClosed
Exception when a writer is closed, and a frame is requested.
Definition: Exceptions.h:264
openshot::TooManySeeks::TooManySeeks
TooManySeeks(string message, string file_path)
Definition: Exceptions.h:258
openshot::ResampleError::file_path
string file_path
Definition: Exceptions.h:247
openshot::TooManySeeks::~TooManySeeks
virtual ~TooManySeeks()
Definition: Exceptions.h:260
openshot::InvalidJSONKey::InvalidJSONKey
InvalidJSONKey(string message, string json)
Definition: Exceptions.h:186
openshot::ErrorEncodingAudio::~ErrorEncodingAudio
virtual ~ErrorEncodingAudio()
Definition: Exceptions.h:97
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: AudioBufferSource.h:45
openshot::InvalidJSONKey::~InvalidJSONKey
virtual ~InvalidJSONKey()
Definition: Exceptions.h:188
openshot::InvalidJSON::file_path
string file_path
Definition: Exceptions.h:155
openshot::ErrorDecodingAudio::~ErrorDecodingAudio
virtual ~ErrorDecodingAudio()
Definition: Exceptions.h:86
openshot::InvalidCodec::InvalidCodec
InvalidCodec(string message, string file_path)
Definition: Exceptions.h:126
openshot::ResampleError::ResampleError
ResampleError(string message, string file_path)
Definition: Exceptions.h:248
openshot::InvalidSampleRate::~InvalidSampleRate
virtual ~InvalidSampleRate()
Definition: Exceptions.h:178
openshot::ErrorEncodingVideo::file_path
string file_path
Definition: Exceptions.h:104
openshot::TooManySeeks::file_path
string file_path
Definition: Exceptions.h:257
openshot::InvalidOptions::file_path
string file_path
Definition: Exceptions.h:165
openshot::TooManySeeks
Exception when too many seek attempts happen.
Definition: Exceptions.h:254
openshot::OutOfBoundsFrame
Exception for frames that are out of bounds.
Definition: Exceptions.h:202
openshot::ErrorEncodingAudio
Exception when encoding audio packet.
Definition: Exceptions.h:90
openshot::OutOfBoundsPoint::~OutOfBoundsPoint
virtual ~OutOfBoundsPoint()
Definition: Exceptions.h:220
openshot::DecklinkError
Exception when accessing a blackmagic decklink card.
Definition: Exceptions.h:70
openshot::OutOfBoundsPoint::OutOfBoundsPoint
OutOfBoundsPoint(string message, int point_requested, int max_points)
Definition: Exceptions.h:218
openshot::InvalidOptions::InvalidOptions
InvalidOptions(string message, string file_path)
Definition: Exceptions.h:166
openshot::BaseException::BaseException
BaseException(string message)
Definition: Exceptions.h:47
openshot::InvalidChannels::~InvalidChannels
virtual ~InvalidChannels()
Definition: Exceptions.h:118
openshot::OutOfBoundsPoint
Exception for an out of bounds key-frame point.
Definition: Exceptions.h:213
openshot::OutOfBoundsFrame::OutOfBoundsFrame
OutOfBoundsFrame(string message, int64_t frame_requested, int64_t max_frames)
Definition: Exceptions.h:207
openshot::ChunkNotFound::chunk_number
int64_t chunk_number
Definition: Exceptions.h:61
openshot::ChunkNotFound
Exception when a required chunk is missing.
Definition: Exceptions.h:56
openshot::OutOfBoundsFrame::MaxFrames
int64_t MaxFrames
Definition: Exceptions.h:206
openshot::ReaderClosed::ReaderClosed
ReaderClosed(string message, string file_path)
Definition: Exceptions.h:238
openshot::ErrorEncodingVideo
Exception when encoding audio packet.
Definition: Exceptions.h:101
openshot::ResampleError
Exception when resample fails.
Definition: Exceptions.h:244
openshot::NoStreamsFound::~NoStreamsFound
virtual ~NoStreamsFound()
Definition: Exceptions.h:198
openshot::InvalidFormat::InvalidFormat
InvalidFormat(string message, string file_path)
Definition: Exceptions.h:146
openshot::ErrorEncodingAudio::frame_number
int64_t frame_number
Definition: Exceptions.h:94
openshot::InvalidChannels::InvalidChannels
InvalidChannels(string message, string file_path)
Definition: Exceptions.h:116
openshot::InvalidJSON
Exception for invalid JSON.
Definition: Exceptions.h:152
openshot::InvalidFormat::~InvalidFormat
virtual ~InvalidFormat()
Definition: Exceptions.h:148
openshot::BaseException
Base exception class with a custom message variable.
Definition: Exceptions.h:42
openshot::InvalidFile::~InvalidFile
virtual ~InvalidFile()
Definition: Exceptions.h:138
openshot::OutOfMemory
Exception when memory could not be allocated.
Definition: Exceptions.h:224
openshot::OutOfMemory::file_path
string file_path
Definition: Exceptions.h:227
openshot::ErrorEncodingVideo::frame_number
int64_t frame_number
Definition: Exceptions.h:105
openshot::NoStreamsFound::NoStreamsFound
NoStreamsFound(string message, string file_path)
Definition: Exceptions.h:196
openshot::OutOfBoundsFrame::FrameRequested
int64_t FrameRequested
Definition: Exceptions.h:205
openshot::ChunkNotFound::chunk_frame
int64_t chunk_frame
Definition: Exceptions.h:62
openshot::ErrorDecodingAudio::frame_number
int64_t frame_number
Definition: Exceptions.h:83
openshot::ChunkNotFound::frame_number
int64_t frame_number
Definition: Exceptions.h:60
openshot::InvalidFile::file_path
string file_path
Definition: Exceptions.h:135
openshot::ErrorDecodingAudio::file_path
string file_path
Definition: Exceptions.h:82
openshot::BaseException::~BaseException
virtual ~BaseException()
Definition: Exceptions.h:48
openshot::InvalidFile
Exception for files that can not be found or opened.
Definition: Exceptions.h:132
openshot::OutOfMemory::OutOfMemory
OutOfMemory(string message, string file_path)
Definition: Exceptions.h:228
openshot::OutOfBoundsPoint::MaxPoints
int MaxPoints
Definition: Exceptions.h:217
openshot::ErrorEncodingAudio::ErrorEncodingAudio
ErrorEncodingAudio(string message, int64_t frame_number)
Definition: Exceptions.h:95
openshot::OutOfBoundsFrame::~OutOfBoundsFrame
virtual ~OutOfBoundsFrame()
Definition: Exceptions.h:209
openshot::InvalidSampleRate::InvalidSampleRate
InvalidSampleRate(string message, string file_path)
Definition: Exceptions.h:176
openshot::InvalidJSON::InvalidJSON
InvalidJSON(string message, string file_path)
Definition: Exceptions.h:156
openshot::ErrorEncodingAudio::file_path
string file_path
Definition: Exceptions.h:93
openshot::WriterClosed::file_path
string file_path
Definition: Exceptions.h:267
openshot::DecklinkError::DecklinkError
DecklinkError(string message)
Definition: Exceptions.h:73
openshot::OutOfMemory::~OutOfMemory
virtual ~OutOfMemory()
Definition: Exceptions.h:230
openshot::ReaderClosed
Exception when a reader is closed, and a frame is requested.
Definition: Exceptions.h:234
openshot::ErrorEncodingVideo::~ErrorEncodingVideo
virtual ~ErrorEncodingVideo()
Definition: Exceptions.h:108
openshot::ReaderClosed::~ReaderClosed
virtual ~ReaderClosed()
Definition: Exceptions.h:240
openshot::ChunkNotFound::ChunkNotFound
ChunkNotFound(string message, int64_t frame_number, int64_t chunk_number, int64_t chunk_frame)
Definition: Exceptions.h:63
openshot::DecklinkError::~DecklinkError
virtual ~DecklinkError()
Definition: Exceptions.h:75
openshot::OutOfBoundsPoint::PointRequested
int PointRequested
Definition: Exceptions.h:216
openshot::InvalidChannels
Exception when an invalid # of audio channels are detected.
Definition: Exceptions.h:112
openshot::InvalidJSON::~InvalidJSON
virtual ~InvalidJSON()
Definition: Exceptions.h:158
openshot::InvalidFile::InvalidFile
InvalidFile(string message, string file_path)
Definition: Exceptions.h:136
openshot::ErrorEncodingVideo::ErrorEncodingVideo
ErrorEncodingVideo(string message, int64_t frame_number)
Definition: Exceptions.h:106
openshot::NoStreamsFound::file_path
string file_path
Definition: Exceptions.h:195
openshot::InvalidJSONKey::json
string json
Definition: Exceptions.h:185
openshot::ChunkNotFound::~ChunkNotFound
virtual ~ChunkNotFound()
Definition: Exceptions.h:65
openshot::InvalidCodec::file_path
string file_path
Definition: Exceptions.h:125
openshot::BaseException::m_message
string m_message
Definition: Exceptions.h:45
openshot::WriterClosed::~WriterClosed
virtual ~WriterClosed()
Definition: Exceptions.h:270
openshot::InvalidOptions::~InvalidOptions
virtual ~InvalidOptions()
Definition: Exceptions.h:168
openshot::InvalidOptions
Exception when invalid encoding options are used.
Definition: Exceptions.h:162
openshot::ErrorDecodingAudio
Exception when decoding audio packet.
Definition: Exceptions.h:79
openshot::NoStreamsFound
Exception when no streams are found in the file.
Definition: Exceptions.h:192
openshot::InvalidJSONKey
Exception for missing JSON Change key.
Definition: Exceptions.h:182
openshot::InvalidCodec::~InvalidCodec
virtual ~InvalidCodec()
Definition: Exceptions.h:128
openshot::BaseException::what
virtual const char * what() const
Definition: Exceptions.h:49
openshot::ResampleError::~ResampleError
virtual ~ResampleError()
Definition: Exceptions.h:250
openshot::InvalidFormat::file_path
string file_path
Definition: Exceptions.h:145
openshot::InvalidSampleRate::file_path
string file_path
Definition: Exceptions.h:175
openshot::WriterClosed::WriterClosed
WriterClosed(string message, string file_path)
Definition: Exceptions.h:268