Exceptions.h
Go to the documentation of this file.
/**
* @file
* @brief Header file for all Exception classes
* @author Jonathan Thomas <jonathan@openshot.org>
*
* @ref License
*/
/* LICENSE
*
* Copyright (c) 2008-2019 OpenShot Studios, LLC
* <http://www.openshotstudios.com/>. This file is part of
* OpenShot Library (libopenshot), an open-source project dedicated to
* delivering high quality video editing and animation solutions to the
* world. For more information visit <http://www.openshot.org/>.
*
* OpenShot Library (libopenshot) is free software: you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* OpenShot Library (libopenshot) is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPENSHOT_EXCEPTIONS_H
#define OPENSHOT_EXCEPTIONS_H
#include <string>
namespace openshot {
/**
* @brief Base exception class with a custom message variable.
*
* A custom error message field has been added to the std::exception base class. All
* OpenShot exception classes inherit from this class.
*/
class BaseException : public std::exception //: public exception
{
protected:
std::string m_message;
public:
BaseException(std::string message) : m_message(message) { }
virtual ~BaseException() noexcept {}
virtual const char* what() const noexcept {
// return custom message
return m_message.c_str();
}
};
/// Exception when a required chunk is missing
class ChunkNotFound : public BaseException
{
public:
int64_t frame_number;
int64_t chunk_number;
int64_t chunk_frame;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param frame_number The frame number being processed
* @param chunk_number The chunk requested
* @param chunk_frame The chunk frame
*/
ChunkNotFound(std::string message, int64_t frame_number, int64_t chunk_number, int64_t chunk_frame)
: BaseException(message), frame_number(frame_number), chunk_number(chunk_number), chunk_frame(chunk_frame) { }
virtual ~ChunkNotFound() noexcept {}
};
/// Exception when accessing a blackmagic decklink card
class DecklinkError : public BaseException
{
public:
/**
* @brief Constructor
*
* @param message A message to accompany the exception
*/
DecklinkError(std::string message)
: BaseException(message) { }
virtual ~DecklinkError() noexcept {}
};
/// Exception when decoding audio packet
class ErrorDecodingAudio : public BaseException
{
public:
int64_t frame_number;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param frame_number The frame number being processed
*/
ErrorDecodingAudio(std::string message, int64_t frame_number)
: BaseException(message), frame_number(frame_number) { }
virtual ~ErrorDecodingAudio() noexcept {}
};
/// Exception when encoding audio packet
class ErrorEncodingAudio : public BaseException
{
public:
int64_t frame_number;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param frame_number The frame number being processed
*/
ErrorEncodingAudio(std::string message, int64_t frame_number)
: BaseException(message), frame_number(frame_number) { }
virtual ~ErrorEncodingAudio() noexcept {}
};
/// Exception when encoding audio packet
class ErrorEncodingVideo : public BaseException
{
public:
int64_t frame_number;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param frame_number The frame number being processed
*/
ErrorEncodingVideo(std::string message, int64_t frame_number)
: BaseException(message), frame_number(frame_number) { }
virtual ~ErrorEncodingVideo() noexcept {}
};
/// Exception when an invalid # of audio channels are detected
class InvalidChannels : public BaseException
{
public:
std::string file_path;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param file_path (optional) The input file being processed
*/
InvalidChannels(std::string message, std::string file_path="")
: BaseException(message), file_path(file_path) { }
virtual ~InvalidChannels() noexcept {}
};
/// Exception when no valid codec is found for a file
class InvalidCodec : public BaseException
{
public:
std::string file_path;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param file_path (optional) The input file being processed
*/
InvalidCodec(std::string message, std::string file_path="")
: BaseException(message), file_path(file_path) { }
virtual ~InvalidCodec() noexcept {}
};
/// Exception for files that can not be found or opened
class InvalidFile : public BaseException
{
public:
std::string file_path;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param file_path The input file being processed
*/
InvalidFile(std::string message, std::string file_path)
: BaseException(message), file_path(file_path) { }
virtual ~InvalidFile() noexcept {}
};
/// Exception when no valid format is found for a file
class InvalidFormat : public BaseException
{
public:
std::string file_path;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param file_path (optional) The input file being processed
*/
InvalidFormat(std::string message, std::string file_path="")
: BaseException(message), file_path(file_path) { }
virtual ~InvalidFormat() noexcept {}
};
/// Exception for invalid JSON
class InvalidJSON : public BaseException
{
public:
std::string file_path;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param file_path (optional) The input file being processed
*/
InvalidJSON(std::string message, std::string file_path="")
: BaseException(message), file_path(file_path) { }
virtual ~InvalidJSON() noexcept {}
};
/// Exception when invalid encoding options are used
class InvalidOptions : public BaseException
{
public:
std::string file_path;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param file_path (optional) The input file being processed
*/
InvalidOptions(std::string message, std::string file_path="")
: BaseException(message), file_path(file_path) { }
virtual ~InvalidOptions() noexcept {}
};
/// Exception when invalid sample rate is detected during encoding
class InvalidSampleRate : public BaseException
{
public:
std::string file_path;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param file_path (optional) The input file being processed
*/
InvalidSampleRate(std::string message, std::string file_path="")
: BaseException(message), file_path(file_path) { }
virtual ~InvalidSampleRate() noexcept {}
};
/// Exception for missing JSON Change key
class InvalidJSONKey : public BaseException
{
public:
std::string json;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param json The json data being processed
*/
InvalidJSONKey(std::string message, std::string json)
: BaseException(message), json(json) { }
virtual ~InvalidJSONKey() noexcept {}
};
/// Exception when no streams are found in the file
class NoStreamsFound : public BaseException
{
public:
std::string file_path;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param file_path (optional) The input file being processed
*/
NoStreamsFound(std::string message, std::string file_path="")
: BaseException(message), file_path(file_path) { }
virtual ~NoStreamsFound() noexcept {}
};
/// Exception for frames that are out of bounds.
class OutOfBoundsFrame : public BaseException
{
public:
int64_t FrameRequested;
int64_t MaxFrames;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param frame_requested The out-of-bounds frame number requested
* @param max_frames The maximum available frame number
*/
OutOfBoundsFrame(std::string message, int64_t frame_requested, int64_t max_frames)
: BaseException(message), FrameRequested(frame_requested), MaxFrames(max_frames) { }
virtual ~OutOfBoundsFrame() noexcept {}
};
/// Exception for an out of bounds key-frame point.
class OutOfBoundsPoint : public BaseException
{
public:
int PointRequested;
int MaxPoints;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param point_requested The out-of-bounds point requested
* @param max_points The maximum available point value
*/
OutOfBoundsPoint(std::string message, int point_requested, int max_points)
: BaseException(message), PointRequested(point_requested), MaxPoints(max_points) { }
virtual ~OutOfBoundsPoint() noexcept {}
};
/// Exception when memory could not be allocated
class OutOfMemory : public BaseException
{
public:
std::string file_path;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param file_path (optional) The input file being processed
*/
OutOfMemory(std::string message, std::string file_path="")
: BaseException(message), file_path(file_path) { }
virtual ~OutOfMemory() noexcept {}
};
/// Exception when a reader is closed, and a frame is requested
class ReaderClosed : public BaseException
{
public:
std::string file_path;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param file_path (optional) The input file being processed
*/
ReaderClosed(std::string message, std::string file_path="")
: BaseException(message), file_path(file_path) { }
virtual ~ReaderClosed() noexcept {}
};
/// Exception when resample fails
class ResampleError : public BaseException
{
public:
std::string file_path;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param file_path (optional) The input file being processed
*/
ResampleError(std::string message, std::string file_path="")
: BaseException(message), file_path(file_path) { }
virtual ~ResampleError() noexcept {}
};
/// Exception when too many seek attempts happen
class TooManySeeks : public BaseException
{
public:
std::string file_path;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param file_path (optional) The input file being processed
*/
TooManySeeks(std::string message, std::string file_path="")
: BaseException(message), file_path(file_path) { }
virtual ~TooManySeeks() noexcept {}
};
/// Exception when a writer is closed, and a frame is requested
class WriterClosed : public BaseException
{
public:
std::string file_path;
/**
* @brief Constructor
*
* @param message A message to accompany the exception
* @param file_path (optional) The output file being written
*/
WriterClosed(std::string message, std::string file_path="")
: BaseException(message), file_path(file_path) { }
virtual ~WriterClosed() noexcept {}
};
}
#endif
openshot::BaseException
Base exception class with a custom message variable.
Definition: Exceptions.h:45
openshot::BaseException::m_message
std::string m_message
Definition: Exceptions.h:47
openshot::BaseException::what
virtual const char * what() const noexcept
Definition: Exceptions.h:51
openshot::BaseException::~BaseException
virtual ~BaseException() noexcept
Definition: Exceptions.h:50
openshot::BaseException::BaseException
BaseException(std::string message)
Definition: Exceptions.h:49
openshot::ChunkNotFound
Exception when a required chunk is missing.
Definition: Exceptions.h:59
openshot::ChunkNotFound::ChunkNotFound
ChunkNotFound(std::string message, int64_t frame_number, int64_t chunk_number, int64_t chunk_frame)
Constructor.
Definition: Exceptions.h:72
openshot::ChunkNotFound::frame_number
int64_t frame_number
Definition: Exceptions.h:61
openshot::ChunkNotFound::~ChunkNotFound
virtual ~ChunkNotFound() noexcept
Definition: Exceptions.h:74
openshot::ChunkNotFound::chunk_frame
int64_t chunk_frame
Definition: Exceptions.h:63
openshot::ChunkNotFound::chunk_number
int64_t chunk_number
Definition: Exceptions.h:62
openshot::DecklinkError
Exception when accessing a blackmagic decklink card.
Definition: Exceptions.h:80
openshot::DecklinkError::DecklinkError
DecklinkError(std::string message)
Constructor.
Definition: Exceptions.h:87
openshot::DecklinkError::~DecklinkError
virtual ~DecklinkError() noexcept
Definition: Exceptions.h:89
openshot::ErrorDecodingAudio
Exception when decoding audio packet.
Definition: Exceptions.h:94
openshot::ErrorDecodingAudio::ErrorDecodingAudio
ErrorDecodingAudio(std::string message, int64_t frame_number)
Constructor.
Definition: Exceptions.h:103
openshot::ErrorDecodingAudio::~ErrorDecodingAudio
virtual ~ErrorDecodingAudio() noexcept
Definition: Exceptions.h:105
openshot::ErrorDecodingAudio::frame_number
int64_t frame_number
Definition: Exceptions.h:96
openshot::ErrorEncodingAudio
Exception when encoding audio packet.
Definition: Exceptions.h:110
openshot::ErrorEncodingAudio::frame_number
int64_t frame_number
Definition: Exceptions.h:112
openshot::ErrorEncodingAudio::ErrorEncodingAudio
ErrorEncodingAudio(std::string message, int64_t frame_number)
Constructor.
Definition: Exceptions.h:119
openshot::ErrorEncodingAudio::~ErrorEncodingAudio
virtual ~ErrorEncodingAudio() noexcept
Definition: Exceptions.h:121
openshot::ErrorEncodingVideo
Exception when encoding audio packet.
Definition: Exceptions.h:126
openshot::ErrorEncodingVideo::frame_number
int64_t frame_number
Definition: Exceptions.h:128
openshot::ErrorEncodingVideo::ErrorEncodingVideo
ErrorEncodingVideo(std::string message, int64_t frame_number)
Constructor.
Definition: Exceptions.h:135
openshot::ErrorEncodingVideo::~ErrorEncodingVideo
virtual ~ErrorEncodingVideo() noexcept
Definition: Exceptions.h:137
openshot::InvalidChannels
Exception when an invalid # of audio channels are detected.
Definition: Exceptions.h:142
openshot::InvalidChannels::InvalidChannels
InvalidChannels(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:151
openshot::InvalidChannels::file_path
std::string file_path
Definition: Exceptions.h:144
openshot::InvalidChannels::~InvalidChannels
virtual ~InvalidChannels() noexcept
Definition: Exceptions.h:153
openshot::InvalidCodec
Exception when no valid codec is found for a file.
Definition: Exceptions.h:158
openshot::InvalidCodec::InvalidCodec
InvalidCodec(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:167
openshot::InvalidCodec::file_path
std::string file_path
Definition: Exceptions.h:160
openshot::InvalidCodec::~InvalidCodec
virtual ~InvalidCodec() noexcept
Definition: Exceptions.h:169
openshot::InvalidFile
Exception for files that can not be found or opened.
Definition: Exceptions.h:174
openshot::InvalidFile::file_path
std::string file_path
Definition: Exceptions.h:176
openshot::InvalidFile::InvalidFile
InvalidFile(std::string message, std::string file_path)
Constructor.
Definition: Exceptions.h:183
openshot::InvalidFile::~InvalidFile
virtual ~InvalidFile() noexcept
Definition: Exceptions.h:185
openshot::InvalidFormat
Exception when no valid format is found for a file.
Definition: Exceptions.h:190
openshot::InvalidFormat::~InvalidFormat
virtual ~InvalidFormat() noexcept
Definition: Exceptions.h:201
openshot::InvalidFormat::InvalidFormat
InvalidFormat(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:199
openshot::InvalidFormat::file_path
std::string file_path
Definition: Exceptions.h:192
openshot::InvalidJSONKey
Exception for missing JSON Change key.
Definition: Exceptions.h:254
openshot::InvalidJSONKey::json
std::string json
Definition: Exceptions.h:256
openshot::InvalidJSONKey::~InvalidJSONKey
virtual ~InvalidJSONKey() noexcept
Definition: Exceptions.h:265
openshot::InvalidJSONKey::InvalidJSONKey
InvalidJSONKey(std::string message, std::string json)
Constructor.
Definition: Exceptions.h:263
openshot::InvalidJSON
Exception for invalid JSON.
Definition: Exceptions.h:206
openshot::InvalidJSON::~InvalidJSON
virtual ~InvalidJSON() noexcept
Definition: Exceptions.h:217
openshot::InvalidJSON::file_path
std::string file_path
Definition: Exceptions.h:208
openshot::InvalidJSON::InvalidJSON
InvalidJSON(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:215
openshot::InvalidOptions
Exception when invalid encoding options are used.
Definition: Exceptions.h:222
openshot::InvalidOptions::file_path
std::string file_path
Definition: Exceptions.h:224
openshot::InvalidOptions::InvalidOptions
InvalidOptions(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:231
openshot::InvalidOptions::~InvalidOptions
virtual ~InvalidOptions() noexcept
Definition: Exceptions.h:233
openshot::InvalidSampleRate
Exception when invalid sample rate is detected during encoding.
Definition: Exceptions.h:238
openshot::InvalidSampleRate::~InvalidSampleRate
virtual ~InvalidSampleRate() noexcept
Definition: Exceptions.h:249
openshot::InvalidSampleRate::InvalidSampleRate
InvalidSampleRate(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:247
openshot::InvalidSampleRate::file_path
std::string file_path
Definition: Exceptions.h:240
openshot::NoStreamsFound
Exception when no streams are found in the file.
Definition: Exceptions.h:270
openshot::NoStreamsFound::file_path
std::string file_path
Definition: Exceptions.h:272
openshot::NoStreamsFound::NoStreamsFound
NoStreamsFound(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:279
openshot::NoStreamsFound::~NoStreamsFound
virtual ~NoStreamsFound() noexcept
Definition: Exceptions.h:281
openshot::OutOfBoundsFrame
Exception for frames that are out of bounds.
Definition: Exceptions.h:286
openshot::OutOfBoundsFrame::OutOfBoundsFrame
OutOfBoundsFrame(std::string message, int64_t frame_requested, int64_t max_frames)
Constructor.
Definition: Exceptions.h:297
openshot::OutOfBoundsFrame::MaxFrames
int64_t MaxFrames
Definition: Exceptions.h:289
openshot::OutOfBoundsFrame::~OutOfBoundsFrame
virtual ~OutOfBoundsFrame() noexcept
Definition: Exceptions.h:299
openshot::OutOfBoundsFrame::FrameRequested
int64_t FrameRequested
Definition: Exceptions.h:288
openshot::OutOfBoundsPoint
Exception for an out of bounds key-frame point.
Definition: Exceptions.h:304
openshot::OutOfBoundsPoint::PointRequested
int PointRequested
Definition: Exceptions.h:306
openshot::OutOfBoundsPoint::MaxPoints
int MaxPoints
Definition: Exceptions.h:307
openshot::OutOfBoundsPoint::~OutOfBoundsPoint
virtual ~OutOfBoundsPoint() noexcept
Definition: Exceptions.h:317
openshot::OutOfBoundsPoint::OutOfBoundsPoint
OutOfBoundsPoint(std::string message, int point_requested, int max_points)
Constructor.
Definition: Exceptions.h:315
openshot::OutOfMemory
Exception when memory could not be allocated.
Definition: Exceptions.h:322
openshot::OutOfMemory::~OutOfMemory
virtual ~OutOfMemory() noexcept
Definition: Exceptions.h:333
openshot::OutOfMemory::file_path
std::string file_path
Definition: Exceptions.h:324
openshot::OutOfMemory::OutOfMemory
OutOfMemory(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:331
openshot::ReaderClosed
Exception when a reader is closed, and a frame is requested.
Definition: Exceptions.h:338
openshot::ReaderClosed::~ReaderClosed
virtual ~ReaderClosed() noexcept
Definition: Exceptions.h:349
openshot::ReaderClosed::file_path
std::string file_path
Definition: Exceptions.h:340
openshot::ReaderClosed::ReaderClosed
ReaderClosed(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:347
openshot::ResampleError
Exception when resample fails.
Definition: Exceptions.h:354
openshot::ResampleError::~ResampleError
virtual ~ResampleError() noexcept
Definition: Exceptions.h:365
openshot::ResampleError::file_path
std::string file_path
Definition: Exceptions.h:356
openshot::ResampleError::ResampleError
ResampleError(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:363
openshot::TooManySeeks
Exception when too many seek attempts happen.
Definition: Exceptions.h:370
openshot::TooManySeeks::file_path
std::string file_path
Definition: Exceptions.h:372
openshot::TooManySeeks::~TooManySeeks
virtual ~TooManySeeks() noexcept
Definition: Exceptions.h:381
openshot::TooManySeeks::TooManySeeks
TooManySeeks(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:379
openshot::WriterClosed
Exception when a writer is closed, and a frame is requested.
Definition: Exceptions.h:386
openshot::WriterClosed::WriterClosed
WriterClosed(std::string message, std::string file_path="")
Constructor.
Definition: Exceptions.h:395
openshot::WriterClosed::~WriterClosed
virtual ~WriterClosed() noexcept
Definition: Exceptions.h:397
openshot::WriterClosed::file_path
std::string file_path
Definition: Exceptions.h:388
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: AudioBufferSource.h:39