X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fexceptions.h;h=a032252163bf79075c26aa408ad7ee5405d9107e;hb=8ba52216d6531b1147999def0c492023a28da857;hp=cb49d864c713b9472cb1b97776c8a94d390e7cfe;hpb=d68bb2ae0e6a3a19c627f9005eed7aca206349cd;p=libsub.git diff --git a/src/exceptions.h b/src/exceptions.h index cb49d86..a032252 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,59 +17,93 @@ */ +#ifndef LIBSUB_EXCEPTIONS_H +#define LIBSUB_EXCEPTIONS_H + +#include #include #include +#include namespace sub { -class MessageError : public std::exception -{ -public: - MessageError (std::string const & message) - : _message (message) {} - ~MessageError () throw () {} - - /** @return error message */ - char const * what () const throw () { - return _message.c_str (); - } - -private: - /** error message */ - std::string _message; -}; - /** @class XMLError * @brief An error raised when reading an XML file. */ -class XMLError : public MessageError +class XMLError : public std::runtime_error { public: XMLError (std::string const & message) - : MessageError (message) + : std::runtime_error (message) {} }; /** @class STLError * @brief An error raised when reading a binary STL file. */ -class STLError : public MessageError +class STLError : public std::runtime_error { public: STLError (std::string const & message) - : MessageError (message) + : std::runtime_error (message) {} }; /** @class SubripError * @brief An error raised when reading a Subrip file. */ -class SubripError : public MessageError +class SubripError : public std::runtime_error { public: - SubripError (std::string saw, std::string expecting) - : MessageError ("Error in SubRip file: saw " + saw + " while expecting " + expecting) + SubripError (std::string saw, std::string expecting, std::list context); + ~SubripError () throw () {} + + std::list context () const { + return _context; + } + +private: + std::list _context; +}; + +class SSAError : public std::runtime_error +{ +public: + SSAError (std::string message) + : std::runtime_error(message) {} }; +class MXFError : public std::runtime_error +{ +public: + MXFError (std::string const & message) + : std::runtime_error (message) + {} +}; + +class UnknownFrameRateError : public std::runtime_error +{ +public: + UnknownFrameRateError () + : std::runtime_error ("unknown frame rate") + {} +}; + +class DCPError : public std::runtime_error +{ +public: + DCPError (std::string const & message) + : std::runtime_error (message) + {} +}; + +class ProgrammingError : public std::runtime_error +{ +public: + ProgrammingError (std::string file, int line); +}; + } + +#endif