From: khizmax Date: Sun, 30 Nov 2014 13:20:54 +0000 (+0300) Subject: Removed cds::Exception class, all exception from the library is based on different... X-Git-Tag: v2.0.0~25 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=libcds.git;a=commitdiff_plain;h=d4d5ca73b8fd17c5e72461a0843e09faa21a876f Removed cds::Exception class, all exception from the library is based on different std exceptions now --- diff --git a/cds/details/defs.h b/cds/details/defs.h index 29389c3f..b9e51a0f 100644 --- a/cds/details/defs.h +++ b/cds/details/defs.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -393,35 +394,6 @@ 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 {}; diff --git a/cds/memory/michael/bound_check.h b/cds/memory/michael/bound_check.h index 02cc7bc0..06cb843f 100644 --- a/cds/memory/michael/bound_check.h +++ b/cds/memory/michael/bound_check.h @@ -72,19 +72,18 @@ namespace cds { namespace memory { namespace michael { 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: - virtual const char * what() const throw() - { - return "Memory bound checking violation"; - } + bound_checker_exception() + : std::out_of_range( "Memory bound checking violation" ) + {} //@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. @@ -103,7 +102,6 @@ namespace cds { namespace memory { namespace michael { throw bound_checker_exception(); } } - //@endcond }; diff --git a/cds/threading/details/pthread_manager.h b/cds/threading/details/pthread_manager.h index ab7b6a8f..fe4e0171 100644 --- a/cds/threading/details/pthread_manager.h +++ b/cds/threading/details/pthread_manager.h @@ -3,6 +3,7 @@ #ifndef __CDS_THREADING_DETAILS_PTHREAD_MANAGER_H #define __CDS_THREADING_DETAILS_PTHREAD_MANAGER_H +#include #include #include #include @@ -23,18 +24,13 @@ namespace cds { namespace threading { 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 - 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 diff --git a/cds/threading/details/wintls_manager.h b/cds/threading/details/wintls_manager.h index 5ffdc981..58137ef3 100644 --- a/cds/threading/details/wintls_manager.h +++ b/cds/threading/details/wintls_manager.h @@ -3,6 +3,7 @@ #ifndef __CDS_THREADING_DETAILS_WINTLS_MANAGER_H #define __CDS_THREADING_DETAILS_WINTLS_MANAGER_H +#include #include #include @@ -22,22 +23,13 @@ namespace cds { namespace threading { 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 ) - : 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(nCode), std::system_category(), pszFunction ) + {} }; //@cond diff --git a/cds/urcu/options.h b/cds/urcu/options.h index c38e7c60..d1bc8b03 100644 --- a/cds/urcu/options.h +++ b/cds/urcu/options.h @@ -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. */ - class rcu_deadlock: public cds::Exception + class rcu_deadlock: public std::logic_error { //@cond - typedef cds::Exception base_class; public: rcu_deadlock() - : base_class( "RCU deadlock detected") + : std::logic_error( "RCU deadlock detected" ) {} //@endcond }; diff --git a/tests/cppunit/cppunit_mini.h b/tests/cppunit/cppunit_mini.h index 81e85017..198f8f00 100644 --- a/tests/cppunit/cppunit_mini.h +++ b/tests/cppunit/cppunit_mini.h @@ -266,7 +266,7 @@ namespace CppUnitMini 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(); \