Loading...
Searching...
No Matches
Exceptions.h
Go to the documentation of this file.
// Copyright (c) 2008-2019 OpenShot Studios, LLC
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#ifndef OPENSHOT_EXCEPTIONS_H
#define OPENSHOT_EXCEPTIONS_H
#include <string>
#include <cstring>
namespace openshot {
class ExceptionBase : public std::exception
{
protected:
std::string m_message;
public:
ExceptionBase(std::string message) : m_message(message) { }
virtual ~ExceptionBase() noexcept {}
virtual const char* what() const noexcept {
// return custom message
return m_message.c_str();
}
virtual std::string py_message() const {
// return complete message for Python exception handling
return m_message;
}
};
class FrameExceptionBase : public ExceptionBase
{
public:
int64_t frame_number;
FrameExceptionBase(std::string message, int64_t frame_number=-1)
: ExceptionBase(message), frame_number(frame_number) { }
virtual std::string py_message() const override {
// return complete message for Python exception handling
std::string out_msg(m_message +
(frame_number > 0
? " at frame " + std::to_string(frame_number)
: ""));
return out_msg;
}
};
class FileExceptionBase : public ExceptionBase
{
public:
std::string file_path;
FileExceptionBase(std::string message, std::string file_path="")
: ExceptionBase(message), file_path(file_path) { }
virtual std::string py_message() const override {
// return complete message for Python exception handling
std::string out_msg(m_message +
(file_path != ""
? " for file " + file_path
: ""));
return out_msg;
}
};
class ChunkNotFound : public FrameExceptionBase
{
public:
int64_t chunk_number;
int64_t chunk_frame;
ChunkNotFound(std::string message, int64_t frame_number, int64_t chunk_number, int64_t chunk_frame)
: FrameExceptionBase(message, frame_number), chunk_number(chunk_number), chunk_frame(chunk_frame) { }
virtual ~ChunkNotFound() noexcept {}
};
class DecklinkError : public ExceptionBase
{
public:
DecklinkError(std::string message)
: ExceptionBase(message) { }
virtual ~DecklinkError() noexcept {}
};
class ErrorDecodingAudio : public FrameExceptionBase
{
public:
ErrorDecodingAudio(std::string message, int64_t frame_number=-1)
: FrameExceptionBase(message, frame_number) { }
virtual ~ErrorDecodingAudio() noexcept {}
};
class ErrorEncodingAudio : public FrameExceptionBase
{
public:
ErrorEncodingAudio(std::string message, int64_t frame_number=-1)
: FrameExceptionBase(message, frame_number) { }
virtual ~ErrorEncodingAudio() noexcept {}
};
class ErrorEncodingVideo : public FrameExceptionBase
{
public:
ErrorEncodingVideo(std::string message, int64_t frame_number=-1)
: FrameExceptionBase(message, frame_number) { }
virtual ~ErrorEncodingVideo() noexcept {}
};
class InvalidChannels : public FileExceptionBase
{
public:
InvalidChannels(std::string message, std::string file_path="")
: FileExceptionBase(message, file_path) { }
virtual ~InvalidChannels() noexcept {}
};
class InvalidCodec : public FileExceptionBase
{
public:
InvalidCodec(std::string message, std::string file_path="")
: FileExceptionBase(message, file_path) { }
virtual ~InvalidCodec() noexcept {}
};
class InvalidFile : public FileExceptionBase
{
public:
InvalidFile(std::string message, std::string file_path)
: FileExceptionBase(message, file_path) { }
virtual ~InvalidFile() noexcept {}
};
class InvalidFormat : public FileExceptionBase
{
public:
InvalidFormat(std::string message, std::string file_path="")
: FileExceptionBase(message, file_path) { }
virtual ~InvalidFormat() noexcept {}
};
class InvalidJSON : public FileExceptionBase
{
public:
InvalidJSON(std::string message, std::string file_path="")
: FileExceptionBase(message, file_path) { }
virtual ~InvalidJSON() noexcept {}
};
class InvalidOptions : public FileExceptionBase
{
public:
InvalidOptions(std::string message, std::string file_path="")
: FileExceptionBase(message, file_path) { }
virtual ~InvalidOptions() noexcept {}
};
class InvalidSampleRate : public FileExceptionBase
{
public:
InvalidSampleRate(std::string message, std::string file_path="")
: FileExceptionBase(message, file_path) { }
virtual ~InvalidSampleRate() noexcept {}
};
class InvalidJSONKey : public ExceptionBase
{
public:
std::string json;
InvalidJSONKey(std::string message, std::string json)
: ExceptionBase(message), json(json) { }
virtual ~InvalidJSONKey() noexcept {}
std::string py_message() const override {
std::string out_msg = m_message +
" for JSON data " +
(json.size() > 100 ? " (abbreviated): " : ": ")
+ json.substr(0, 99);
return out_msg;
}
};
class NoStreamsFound : public FileExceptionBase
{
public:
NoStreamsFound(std::string message, std::string file_path="")
: FileExceptionBase(message, file_path) { }
virtual ~NoStreamsFound() noexcept {}
};
class OutOfBoundsFrame : public ExceptionBase
{
public:
int64_t FrameRequested;
int64_t MaxFrames;
OutOfBoundsFrame(std::string message, int64_t frame_requested, int64_t max_frames)
: ExceptionBase(message), FrameRequested(frame_requested), MaxFrames(max_frames) { }
virtual ~OutOfBoundsFrame() noexcept {}
std::string py_message() const override {
std::string out_msg(m_message
+ " Frame requested: " + std::to_string(FrameRequested)
+ " Max frames: " + std::to_string(MaxFrames));
return out_msg;
}
};
class OutOfBoundsPoint : public ExceptionBase
{
public:
int PointRequested;
int MaxPoints;
OutOfBoundsPoint(std::string message, int point_requested, int max_points)
: ExceptionBase(message), PointRequested(point_requested), MaxPoints(max_points) { }
virtual ~OutOfBoundsPoint() noexcept {}
std::string py_message() const override {
std::string out_msg(m_message
+ " Point requested: " + std::to_string(PointRequested)
+ " Max point: " + std::to_string(MaxPoints));
return out_msg;
}
};
class OutOfMemory : public FileExceptionBase
{
public:
OutOfMemory(std::string message, std::string file_path="")
: FileExceptionBase(message, file_path) { }
virtual ~OutOfMemory() noexcept {}
};
class ReaderClosed : public FileExceptionBase
{
public:
ReaderClosed(std::string message, std::string file_path="")
: FileExceptionBase(message, file_path) { }
virtual ~ReaderClosed() noexcept {}
};
class ResampleError : public FileExceptionBase
{
public:
ResampleError(std::string message, std::string file_path="")
: FileExceptionBase(message, file_path) { }
virtual ~ResampleError() noexcept {}
};
#define TMS_DEP_MSG "The library no longer throws this exception. It will be removed in a future release."
#ifndef SWIG
class
[[deprecated(TMS_DEP_MSG)]]
TooManySeeks : public FileExceptionBase
{
public:
[[deprecated(TMS_DEP_MSG)]]
TooManySeeks(std::string message, std::string file_path="")
: FileExceptionBase(message, file_path) { }
virtual ~TooManySeeks() noexcept {}
};
#endif
class WriterClosed : public FileExceptionBase
{
public:
WriterClosed(std::string message, std::string file_path="")
: FileExceptionBase(message, file_path) { }
virtual ~WriterClosed() noexcept {}
};
}
#endif
TMS_DEP_MSG
#define TMS_DEP_MSG
Definition Exceptions.h:392
openshot::ChunkNotFound::ChunkNotFound
ChunkNotFound(std::string message, int64_t frame_number, int64_t chunk_number, int64_t chunk_frame)
Constructor.
Definition Exceptions.h:91
openshot::ChunkNotFound::~ChunkNotFound
virtual ~ChunkNotFound() noexcept
Definition Exceptions.h:93
openshot::ChunkNotFound::chunk_frame
int64_t chunk_frame
Definition Exceptions.h:82
openshot::ChunkNotFound::chunk_number
int64_t chunk_number
Definition Exceptions.h:81
openshot::DecklinkError::DecklinkError
DecklinkError(std::string message)
Constructor.
Definition Exceptions.h:106
openshot::DecklinkError::~DecklinkError
virtual ~DecklinkError() noexcept
Definition Exceptions.h:108
openshot::ErrorDecodingAudio::~ErrorDecodingAudio
virtual ~ErrorDecodingAudio() noexcept
Definition Exceptions.h:123
openshot::ErrorDecodingAudio::ErrorDecodingAudio
ErrorDecodingAudio(std::string message, int64_t frame_number=-1)
Constructor.
Definition Exceptions.h:121
openshot::ErrorEncodingAudio::ErrorEncodingAudio
ErrorEncodingAudio(std::string message, int64_t frame_number=-1)
Constructor.
Definition Exceptions.h:136
openshot::ErrorEncodingAudio::~ErrorEncodingAudio
virtual ~ErrorEncodingAudio() noexcept
Definition Exceptions.h:138
openshot::ErrorEncodingVideo::~ErrorEncodingVideo
virtual ~ErrorEncodingVideo() noexcept
Definition Exceptions.h:153
openshot::ErrorEncodingVideo::ErrorEncodingVideo
ErrorEncodingVideo(std::string message, int64_t frame_number=-1)
Constructor.
Definition Exceptions.h:151
openshot::ExceptionBase::~ExceptionBase
virtual ~ExceptionBase() noexcept
Definition Exceptions.h:33
openshot::ExceptionBase::py_message
virtual std::string py_message() const
Definition Exceptions.h:38
openshot::ExceptionBase::m_message
std::string m_message
Definition Exceptions.h:30
openshot::ExceptionBase::ExceptionBase
ExceptionBase(std::string message)
Definition Exceptions.h:32
openshot::ExceptionBase::what
virtual const char * what() const noexcept
Definition Exceptions.h:34
openshot::FileExceptionBase::FileExceptionBase
FileExceptionBase(std::string message, std::string file_path="")
Definition Exceptions.h:65
openshot::FileExceptionBase::py_message
virtual std::string py_message() const override
Definition Exceptions.h:67
openshot::FileExceptionBase::file_path
std::string file_path
Definition Exceptions.h:64
openshot::FrameExceptionBase::FrameExceptionBase
FrameExceptionBase(std::string message, int64_t frame_number=-1)
Definition Exceptions.h:48
openshot::FrameExceptionBase::frame_number
int64_t frame_number
Definition Exceptions.h:47
openshot::FrameExceptionBase::py_message
virtual std::string py_message() const override
Definition Exceptions.h:50
openshot::InvalidChannels::InvalidChannels
InvalidChannels(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:166
openshot::InvalidChannels::~InvalidChannels
virtual ~InvalidChannels() noexcept
Definition Exceptions.h:168
openshot::InvalidCodec::InvalidCodec
InvalidCodec(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:181
openshot::InvalidCodec::~InvalidCodec
virtual ~InvalidCodec() noexcept
Definition Exceptions.h:183
openshot::InvalidFile::InvalidFile
InvalidFile(std::string message, std::string file_path)
Constructor.
Definition Exceptions.h:196
openshot::InvalidFile::~InvalidFile
virtual ~InvalidFile() noexcept
Definition Exceptions.h:198
openshot::InvalidFormat::~InvalidFormat
virtual ~InvalidFormat() noexcept
Definition Exceptions.h:213
openshot::InvalidFormat::InvalidFormat
InvalidFormat(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:211
openshot::InvalidJSONKey::json
std::string json
Definition Exceptions.h:265
openshot::InvalidJSONKey::py_message
std::string py_message() const override
Definition Exceptions.h:275
openshot::InvalidJSONKey::~InvalidJSONKey
virtual ~InvalidJSONKey() noexcept
Definition Exceptions.h:274
openshot::InvalidJSONKey::InvalidJSONKey
InvalidJSONKey(std::string message, std::string json)
Constructor.
Definition Exceptions.h:272
openshot::InvalidJSON::~InvalidJSON
virtual ~InvalidJSON() noexcept
Definition Exceptions.h:228
openshot::InvalidJSON::InvalidJSON
InvalidJSON(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:226
openshot::InvalidOptions::InvalidOptions
InvalidOptions(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:241
openshot::InvalidOptions::~InvalidOptions
virtual ~InvalidOptions() noexcept
Definition Exceptions.h:243
openshot::InvalidSampleRate::~InvalidSampleRate
virtual ~InvalidSampleRate() noexcept
Definition Exceptions.h:258
openshot::InvalidSampleRate::InvalidSampleRate
InvalidSampleRate(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:256
openshot::NoStreamsFound::NoStreamsFound
NoStreamsFound(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:294
openshot::NoStreamsFound::~NoStreamsFound
virtual ~NoStreamsFound() noexcept
Definition Exceptions.h:296
openshot::OutOfBoundsFrame::OutOfBoundsFrame
OutOfBoundsFrame(std::string message, int64_t frame_requested, int64_t max_frames)
Constructor.
Definition Exceptions.h:312
openshot::OutOfBoundsFrame::MaxFrames
int64_t MaxFrames
Definition Exceptions.h:304
openshot::OutOfBoundsFrame::~OutOfBoundsFrame
virtual ~OutOfBoundsFrame() noexcept
Definition Exceptions.h:314
openshot::OutOfBoundsFrame::py_message
std::string py_message() const override
Definition Exceptions.h:315
openshot::OutOfBoundsFrame::FrameRequested
int64_t FrameRequested
Definition Exceptions.h:303
openshot::OutOfBoundsPoint::PointRequested
int PointRequested
Definition Exceptions.h:327
openshot::OutOfBoundsPoint::py_message
std::string py_message() const override
Definition Exceptions.h:339
openshot::OutOfBoundsPoint::MaxPoints
int MaxPoints
Definition Exceptions.h:328
openshot::OutOfBoundsPoint::~OutOfBoundsPoint
virtual ~OutOfBoundsPoint() noexcept
Definition Exceptions.h:338
openshot::OutOfBoundsPoint::OutOfBoundsPoint
OutOfBoundsPoint(std::string message, int point_requested, int max_points)
Constructor.
Definition Exceptions.h:336
openshot::OutOfMemory::~OutOfMemory
virtual ~OutOfMemory() noexcept
Definition Exceptions.h:359
openshot::OutOfMemory::OutOfMemory
OutOfMemory(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:357
openshot::ReaderClosed::~ReaderClosed
virtual ~ReaderClosed() noexcept
Definition Exceptions.h:374
openshot::ReaderClosed::ReaderClosed
ReaderClosed(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:372
openshot::ResampleError::~ResampleError
virtual ~ResampleError() noexcept
Definition Exceptions.h:389
openshot::ResampleError::ResampleError
ResampleError(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:387
openshot::TooManySeeks::~TooManySeeks
virtual ~TooManySeeks() noexcept
Definition Exceptions.h:410
openshot::TooManySeeks::TooManySeeks
TooManySeeks(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:408
openshot::WriterClosed::WriterClosed
WriterClosed(std::string message, std::string file_path="")
Constructor.
Definition Exceptions.h:424
openshot::WriterClosed::~WriterClosed
virtual ~WriterClosed() noexcept
Definition Exceptions.h:426
openshot
This namespace is the default namespace for all code in the openshot library.
Definition Compressor.h:29