Removed cds::Exception class, all exception from the library is based on different...
authorkhizmax <libcds.dev@gmail.com>
Sun, 30 Nov 2014 13:20:54 +0000 (16:20 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sun, 30 Nov 2014 13:20:54 +0000 (16:20 +0300)
cds/details/defs.h
cds/memory/michael/bound_check.h
cds/threading/details/pthread_manager.h
cds/threading/details/wintls_manager.h
cds/urcu/options.h
tests/cppunit/cppunit_mini.h

index 29389c3f49b3e461d516664d0a2b5741ab5bbbde..b9e51a0f5812bbc28ed6a037d3748079af36dd72 100644 (file)
@@ -7,6 +7,7 @@
 #include <assert.h>
 #include <cstdint>
 #include <exception>
 #include <assert.h>
 #include <cstdint>
 #include <exception>
+#include <stdexcept>
 #include <string>
 #include <memory>
 
 #include <string>
 #include <memory>
 
@@ -393,35 +394,6 @@ namespace cds {
 
 namespace cds {
 
 
 namespace cds {
 
-    /// Base of all exceptions in the library
-    class Exception: public std::exception
-    {
-    protected:
-        std::string    m_strMsg    ;    ///< Exception message
-    public:
-        /// Create empty exception
-        Exception()
-        {}
-        /// Create exception with message
-        explicit Exception( const char * pszMsg )
-            : m_strMsg( pszMsg )
-        {}
-        /// Create exception with message
-        explicit Exception( const std::string& strMsg )
-            :m_strMsg( strMsg )
-        {}
-
-        /// Destructor
-        virtual ~Exception() throw()
-        {}
-
-        /// Return exception message
-        virtual const char * what( ) const throw()
-        {
-            return m_strMsg.c_str();
-        }
-    };
-
     /// any_type is used as a placeholder for auto-calculated type (usually in \p rebind templates)
     struct any_type {};
 
     /// any_type is used as a placeholder for auto-calculated type (usually in \p rebind templates)
     struct any_type {};
 
index 02cc7bc0b909339b3fa93e08ca3d093cde6f2e0f..06cb843fd4d6d6dec87621e9c87caaf82f5df896 100644 (file)
@@ -72,19 +72,18 @@ namespace cds { namespace memory { namespace michael {
     typedef cds::opt::none  debug_bound_checking;
 #endif
 
     typedef cds::opt::none  debug_bound_checking;
 #endif
 
-    /// %Exception of \ref strong_bound_checking bound checker
-    class bound_checker_exception: public std::exception
+    /// Exception of \ref strong_bound_checking bound checker
+    class bound_checker_exception: public std::out_of_range
     {
     //@cond
     public:
     {
     //@cond
     public:
-        virtual const char * what() const throw()
-        {
-            return "Memory bound checking violation";
-        }
+        bound_checker_exception()
+            : std::out_of_range( "Memory bound checking violation" )
+        {}
     //@endcond
     };
 
     //@endcond
     };
 
-    /// %Exception throwing bound checker
+    /// Exception throwing bound checker
     /**
         This is one of value of opt::check_bounds option for Michael's \ref Heap memory allocator.
         It is intended for debug and release mode.
     /**
         This is one of value of opt::check_bounds option for Michael's \ref Heap memory allocator.
         It is intended for debug and release mode.
@@ -103,7 +102,6 @@ namespace cds { namespace memory { namespace michael {
                 throw bound_checker_exception();
             }
         }
                 throw bound_checker_exception();
             }
         }
-
     //@endcond
     };
 
     //@endcond
     };
 
index ab7b6a8f011a9893897e7cf48d5477676a8da5d4..fe4e0171b7f9a97d61d756e4e658af20520f14cd 100644 (file)
@@ -3,6 +3,7 @@
 #ifndef __CDS_THREADING_DETAILS_PTHREAD_MANAGER_H
 #define __CDS_THREADING_DETAILS_PTHREAD_MANAGER_H
 
 #ifndef __CDS_THREADING_DETAILS_PTHREAD_MANAGER_H
 #define __CDS_THREADING_DETAILS_PTHREAD_MANAGER_H
 
+#include <system_error>
 #include <stdio.h>
 #include <pthread.h>
 #include <cds/threading/details/_common.h>
 #include <stdio.h>
 #include <pthread.h>
 #include <cds/threading/details/_common.h>
@@ -23,18 +24,13 @@ namespace cds { namespace threading {
             typedef int pthread_error_code;
 
             /// pthread exception
             typedef int pthread_error_code;
 
             /// pthread exception
-            class pthread_exception: public cds::Exception {
-            public:
-                const pthread_error_code    m_errCode   ;   ///< pthread error code, -1 if no pthread error code
+            class pthread_exception: public std::system_error
+            {
             public:
                 /// Exception constructor
             public:
                 /// Exception constructor
-                pthread_exception( pthread_error_code nCode, const char * pszFunction )
-                    : m_errCode( nCode )
-                {
-                    char buf[256];
-                    sprintf( buf, "Pthread error %i [function %s]", nCode, pszFunction );
-                    m_strMsg = buf;
-                }
+                pthread_exception( int nCode, const char * pszFunction )
+                    : std::system_error( nCode, std::system_category(), pszFunction )
+                {}
             };
 
             /// pthread TLS key holder
             };
 
             /// pthread TLS key holder
index 5ffdc9817d9e7f0a88caf14b5cf21d974aa7672e..58137ef3d0a66047c4aa25a6a9cbadc9a1acfd24 100644 (file)
@@ -3,6 +3,7 @@
 #ifndef __CDS_THREADING_DETAILS_WINTLS_MANAGER_H
 #define __CDS_THREADING_DETAILS_WINTLS_MANAGER_H
 
 #ifndef __CDS_THREADING_DETAILS_WINTLS_MANAGER_H
 #define __CDS_THREADING_DETAILS_WINTLS_MANAGER_H
 
+#include <system_error>
 #include <stdio.h>
 #include <cds/threading/details/_common.h>
 
 #include <stdio.h>
 #include <cds/threading/details/_common.h>
 
@@ -22,22 +23,13 @@ namespace cds { namespace threading {
             typedef DWORD api_error_code;
 
             /// TLS API exception
             typedef DWORD api_error_code;
 
             /// TLS API exception
-            class api_exception: public cds::Exception {
-            public:
-                const api_error_code    m_errCode   ;   ///< error code
+            class api_exception : public std::system_error
+            {
             public:
                 /// Exception constructor
                 api_exception( api_error_code nCode, const char * pszFunction )
             public:
                 /// Exception constructor
                 api_exception( api_error_code nCode, const char * pszFunction )
-                    : m_errCode( nCode )
-                {
-                    char buf[256];
-#           if CDS_OS_TYPE == CDS_OS_MINGW
-                    sprintf( buf, "Win32 TLS API error %lu [function %s]", nCode, pszFunction );
-#           else
-                    sprintf_s( buf, sizeof(buf)/sizeof(buf[0]), "Win32 TLS API error %lu [function %s]", nCode, pszFunction );
-#           endif
-                    m_strMsg = buf;
-                }
+                    : std::system_error( static_cast<int>(nCode), std::system_category(), pszFunction )
+                {}
             };
 
             //@cond
             };
 
             //@cond
index c38e7c60c4ae8d2c757fbdbcbad1a9d683dea2da..d1bc8b035534ffe2789b2c7bb2bb1da5d41e83ed 100644 (file)
@@ -11,13 +11,12 @@ namespace cds { namespace urcu {
         This exception is raised when \p cds::opt::v::rcu_throw_deadlock deadlock checking policy
         is used, see \p cds::opt::rcu_check_deadlock option.
     */
         This exception is raised when \p cds::opt::v::rcu_throw_deadlock deadlock checking policy
         is used, see \p cds::opt::rcu_check_deadlock option.
     */
-    class rcu_deadlock: public cds::Exception
+    class rcu_deadlock: public std::logic_error
     {
         //@cond
     {
         //@cond
-        typedef cds::Exception base_class;
     public:
         rcu_deadlock()
     public:
         rcu_deadlock()
-            : base_class( "RCU deadlock detected")
+            : std::logic_error( "RCU deadlock detected" )
         {}
         //@endcond
     };
         {}
         //@endcond
     };
index 81e85017d457e2af027df9460a54657b8c01dac5..198f8f0083839ea304a062b6c8a00d607073c4fd 100644 (file)
@@ -266,7 +266,7 @@ namespace CppUnitMini
           X(); \
         } \
         catch(...) { \
           X(); \
         } \
         catch(...) { \
-          Base::error("Test Failed: An Exception was thrown.", #X, __FILE__, __LINE__); \
+          Base::error("Test Failed: An exception was thrown.", #X, __FILE__, __LINE__); \
         } \
       } \
       tearDown(); \
         } \
       } \
       tearDown(); \