X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fexceptions.h;h=7240611ee7757b3acc760ed0acb9f4e2d571e794;hb=1ad291db7e847fbb71e5bd9f2f81db6bfb2a022e;hp=52f257a8d3f558550ccba9724dfe612e3eca55c0;hpb=2d24bc7aaed800415bce4fffe06f261d5e9e464a;p=dcpomatic.git diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h index 52f257a8d..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 () {} @@ -259,46 +257,10 @@ public: InvalidSignerError (); }; -/** @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 ProgrammingError : 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 (); - } - -private: - boost::exception_ptr _exception; - mutable boost::mutex _mutex; + ProgrammingError (std::string file, int line); }; #endif