diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-02-11 00:18:40 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-02-11 00:18:40 +0000 |
| commit | beea3beacba34c11b6b73323f4c3c8590a9aa73e (patch) | |
| tree | 70c7507dff9e52bddbe1052129e408a4b1df3764 /src/lib/exceptions.h | |
| parent | b45f90d8d504c15b60d2ae3a3344e8beb2947f8a (diff) | |
Basic attempt to catch exceptions in the writer thread and pass them safely back to the GUI.
Diffstat (limited to 'src/lib/exceptions.h')
| -rw-r--r-- | src/lib/exceptions.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h index bf8e85f0b..e757d2506 100644 --- a/src/lib/exceptions.h +++ b/src/lib/exceptions.h @@ -17,6 +17,9 @@ */ +#ifndef DVDOMATIC_EXCEPTIONS_H +#define DVDOMATIC_EXCEPTIONS_H + /** @file src/exceptions.h * @brief Our exceptions. */ @@ -24,6 +27,8 @@ #include <stdexcept> #include <sstream> #include <cstring> +#include <boost/exception/all.hpp> +#include <boost/thread.hpp> /** @class StringError * @brief A parent class for exceptions using messages held in a std::string @@ -224,3 +229,30 @@ public: : StringError (s) {} }; + +class ExceptionStore +{ +public: + bool thrown () const { + boost::mutex::scoped_lock lm (_mutex); + return _exception; + } + + void rethrow () { + boost::mutex::scoped_lock lm (_mutex); + boost::rethrow_exception (_exception); + } + +protected: + + void store_current () { + boost::mutex::scoped_lock lm (_mutex); + _exception = boost::current_exception (); + } + +private: + boost::exception_ptr _exception; + mutable boost::mutex _mutex; +}; + +#endif |
