]> git.sesse.net Git - casparcg/blobdiff - common/except.h
- Removed need of non-deterministic sleeps during server shutdown.
[casparcg] / common / except.h
index b0ce1c8e125c4196db62970129d0eef339d2fc5a..9bdc05ccff4a2cdaec3cf6b42d94d65025eec550 100644 (file)
 
 #include "utf.h"
 
-#include "log.h"
+#include "os/stack_trace.h"
 
 #include <exception>
 #include <boost/exception/all.hpp>
 #include <boost/exception/error_info.hpp>
 #include <boost/throw_exception.hpp>
 
-struct _EXCEPTION_RECORD;
-struct _EXCEPTION_POINTERS;
-
-typedef _EXCEPTION_RECORD EXCEPTION_RECORD;
-typedef _EXCEPTION_POINTERS EXCEPTION_POINTERS;
-
 namespace caspar {
 
 typedef boost::error_info<struct tag_arg_name_info, std::string>       arg_name_info_t;
@@ -67,7 +61,13 @@ typedef boost::error_info<struct tag_nested_exception_, std::exception_ptr> nest
 struct caspar_exception                        : virtual boost::exception, virtual std::exception 
 {
        caspar_exception(){}
-       explicit caspar_exception(const char* msg) : std::exception(msg) {}
+       explicit caspar_exception(const char* msg) : msg_(msg) {}
+       const char* what() const throw() override
+       {
+               return msg_;
+       }
+private:
+       const char* msg_ = "";
 };
 
 struct io_error                                        : virtual caspar_exception {};
@@ -79,6 +79,7 @@ struct file_write_error         : virtual io_error {};
 struct invalid_argument                        : virtual caspar_exception {};
 struct null_argument                   : virtual invalid_argument {};
 struct out_of_range                            : virtual invalid_argument {};
+struct programming_error               : virtual caspar_exception {};
 struct bad_alloc                               : virtual caspar_exception {};
 
 struct invalid_operation               : virtual caspar_exception {};
@@ -88,65 +89,7 @@ struct timed_out                             : virtual caspar_exception {};
 struct not_supported                   : virtual caspar_exception {};
 struct not_implemented                 : virtual caspar_exception {};
 
-class win32_exception : public std::exception
-{
-public:
-       typedef const void* address;
-       static void install_handler();
-
-       address location() const { return location_; }
-       unsigned int error_code() const { return errorCode_; }
-       virtual const char* what() const { return message_;     }
-
-protected:
-       win32_exception(const EXCEPTION_RECORD& info);
-       static void Handler(unsigned int errorCode, EXCEPTION_POINTERS* pInfo);
-
-private:
-       const char* message_;
+#define CASPAR_THROW_EXCEPTION(e) BOOST_THROW_EXCEPTION(e << call_stack_info(caspar::get_call_stack()))
 
-       address location_;
-       unsigned int errorCode_;
-};
-
-class win32_access_violation : public win32_exception
-{
-       mutable char messageBuffer_[256];
-
-public:
-       bool is_write() const { return isWrite_; }
-       address bad_address() const { return badAddress_;}
-       virtual const char* what() const;
-
-protected:
-       win32_access_violation(const EXCEPTION_RECORD& info);
-       friend void win32_exception::Handler(unsigned int errorCode, EXCEPTION_POINTERS* pInfo);
-
-private:
-       bool isWrite_;
-       address badAddress_;
-};
-
-#define CASPAR_THROW_EXCEPTION(e) BOOST_THROW_EXCEPTION(e << call_stack_info(caspar::log::internal::get_call_stack()))
-
-}
-
-namespace std
-{
-
-inline bool operator!=(const std::exception_ptr& lhs, const std::exception_ptr& rhs)
-{
-       return !(lhs == rhs);
-}
-
-inline bool operator!=(const std::exception_ptr& lhs, std::nullptr_t)
-{
-       return !(lhs == nullptr);
-}
-
-inline bool operator!=(std::nullptr_t, const std::exception_ptr& rhs)
-{
-       return !(nullptr == rhs);
 }
 
-}
\ No newline at end of file