X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fexceptions.h;h=7240611ee7757b3acc760ed0acb9f4e2d571e794;hb=1ad291db7e847fbb71e5bd9f2f81db6bfb2a022e;hp=38452ffc02b7c0867596cb55787a77c29eeafc01;hpb=308488324dbc4d8b709d3fb1dc9fee0479346c21;p=dcpomatic.git diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h index 38452ffc0..7240611ee 100644 --- a/src/lib/exceptions.h +++ b/src/lib/exceptions.h @@ -24,14 +24,12 @@ #ifndef DCPOMATIC_EXCEPTIONS_H #define DCPOMATIC_EXCEPTIONS_H -#include -#include -#include -#include -#include extern "C" { #include } +#include +#include +#include /** @class StringError * @brief A parent class for exceptions using messages held in a std::string @@ -40,9 +38,9 @@ class StringError : public std::exception { public: /** @param w Error message */ - StringError (std::string w) { - _what = w; - } + StringError (std::string w) + : _what (w) + {} virtual ~StringError () throw () {} @@ -245,48 +243,24 @@ public: SubRipError (std::string, std::string, boost::filesystem::path); }; -/** @class ExceptionStore - * @brief A parent class for classes which have a need to catch and - * re-throw exceptions. - - * This is intended for classes which run their own thread; they should do - * something like - * - * void my_thread () - * try { - * // do things which might throw exceptions - * } catch (...) { - * store_current (); - * } - * - * and then in another thread call rethrow(). If any - * exception was thrown by my_thread it will be stored by - * store_current() and then rethrow() will re-throw it where - * it can be handled. - */ -class ExceptionStore +class DCPError : public StringError { public: - void rethrow () { - boost::mutex::scoped_lock lm (_mutex); - if (_exception) { - boost::rethrow_exception (_exception); - _exception = boost::exception_ptr (); - } - } - -protected: - - void store_current () { - boost::mutex::scoped_lock lm (_mutex); - _exception = boost::current_exception (); - } + DCPError (std::string s) + : StringError (s) + {} +}; -private: - boost::exception_ptr _exception; - mutable boost::mutex _mutex; +class InvalidSignerError : public StringError +{ +public: + InvalidSignerError (); }; - +class ProgrammingError : public StringError +{ +public: + ProgrammingError (std::string file, int line); +}; #endif