X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fexceptions.h;h=6939f81a34765b68366d5b958019299e4a3f3ab8;hp=52f257a8d3f558550ccba9724dfe612e3eca55c0;hb=aeb835a18c8df347e0ed68fb24631b320abeb611;hpb=3b48d5494c3cae7743d283203f5c8021860ab81f diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h index 52f257a8d..6939f81a3 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,18 @@ 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 (); - } + ProgrammingError (std::string file, int line); +}; -private: - boost::exception_ptr _exception; - mutable boost::mutex _mutex; +class TextEncodingError : public StringError +{ +public: + TextEncodingError (std::string s) + : StringError (s) + {} }; #endif