diff --git a/doc/reference.html b/doc/reference.html index 2381252..be513cd 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -689,7 +689,10 @@ application program interfaces.

{ public: system_error( error_code ec ); + system_error( error_code ec, const char * what_arg ); system_error( error_code ec, const std::string & what_arg ); + system_error( error_code::value_type ev, const error_category & ecat, + const char * what_arg ); system_error( error_code::value_type ev, const error_category & ecat, const std::string & what_arg ); system_error( error_code::value_type ev, const error_category & ecat); @@ -706,12 +709,25 @@ application program interfaces.

Postcondition: code() == ec
  && std::strcmp( this->runtime_error::what(), "" ) == 0

+
system_error( error_code ec, const char * what_arg );
+
+

Effects: Constructs an object of class system_error.

+

Postcondition: code() == ec
+  && std::strcmp( this->runtime_error::what(), what_arg ) == 0

+
system_error( error_code ec, const std::string & what_arg );

Effects: Constructs an object of class system_error.

Postcondition: code() == ec
  && std::strcmp( this->runtime_error::what(), what_arg.c_str() ) == 0

+
system_error( error_code::value_type ev, const error_category & ecat,
+             const char * what_arg );
+
+

Effects: Constructs an object of class system_error.

+

Postcondition: code() == error_code( ev, ecat )
+  && std::strcmp( this->runtime_error::what(), what_arg ) == 0

+
system_error( error_code::value_type ev, const error_category & ecat,
              const std::string & what_arg );
@@ -743,7 +759,7 @@ Distributed under the Boost Software License, Version 1.0. See www.boost.org/LICENSE_1_0.txt

Revised -June 24, 2008 +June 25, 2008

diff --git a/include/boost/system/system_error.hpp b/include/boost/system/system_error.hpp index 3b4204b..4091647 100644 --- a/include/boost/system/system_error.hpp +++ b/include/boost/system/system_error.hpp @@ -24,13 +24,23 @@ namespace boost public: system_error( error_code ec ) : std::runtime_error(""), m_error_code(ec) {} + system_error( error_code ec, const std::string & what_arg ) : std::runtime_error(what_arg), m_error_code(ec) {} + + system_error( error_code ec, const char* what_arg ) + : std::runtime_error(what_arg), m_error_code(ec) {} + + system_error( int ev, const error_category & ecat ) + : std::runtime_error(""), m_error_code(ev,ecat) {} + system_error( int ev, const error_category & ecat, const std::string & what_arg ) : std::runtime_error(what_arg), m_error_code(ev,ecat) {} - system_error( int ev, const error_category & ecat ) - : std::runtime_error(""), m_error_code(ev,ecat) {} + + system_error( int ev, const error_category & ecat, + const char * what_arg ) + : std::runtime_error(what_arg), m_error_code(ev,ecat) {} virtual ~system_error() throw() {} diff --git a/test/system_error_test.cpp b/test/system_error_test.cpp index d49ced4..269fb5d 100644 --- a/test/system_error_test.cpp +++ b/test/system_error_test.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #ifdef BOOST_WINDOWS_API #include @@ -22,6 +23,7 @@ using boost::system::system_error; using boost::system::error_code; using boost::system::system_category; +using std::string; #define TEST(x,v,w) test(#x,x,v,w) @@ -51,29 +53,52 @@ namespace # endif } - const boost::uint_least32_t uvalue = 1u; + const boost::uint_least32_t uvalue = 2u; } int test_main( int, char *[] ) { - // all combinations of constructors: + // all constructors, in the same order as they appear in the header: - system_error se_0_m( error_code(0, system_category), "se_0_m" ); - system_error se_1_m( 1, system_category, "se_1_m" ); - system_error se_0_nm( error_code(0, system_category), "" ); - system_error se_1_nm( 1, system_category, "" ); - system_error se_0_nmx( error_code(0, system_category), "" ); - system_error se_1_nmx( 1, system_category, "" ); - system_error se_1u_m( uvalue, system_category, "se_1u_m" ); + system_error c1_0( error_code(0, system_category) ); + system_error c1_1( error_code(1, system_category) ); + system_error c1_2u( error_code(uvalue, system_category) ); - TEST( se_0_m, 0, "se_0_m" ); - TEST( se_1_m, 1, "se_1_m: Incorrect function" ); - TEST( se_0_nm, 0, "" ); - TEST( se_1_nm, 1, "Incorrect function" ); - TEST( se_0_nmx, 0, "" ); - TEST( se_1_nmx, 1, "Incorrect function" ); - TEST( se_1u_m, 1, "se_1u_m: Incorrect function" ); + system_error c2_0( error_code(0, system_category), string("c2_0") ); + system_error c2_1( error_code(1, system_category), string("c2_1") ); + system_error c3_0( error_code(0, system_category), "c3_0" ); + system_error c3_1( error_code(1, system_category), "c3_1" ); + + system_error c4_0( 0, system_category ); + system_error c4_1( 1, system_category ); + system_error c4_2u( uvalue, system_category ); + + system_error c5_0( 0, system_category, string("c5_0") ); + system_error c5_1( 1, system_category, string("c5_1") ); + + system_error c6_0( 0, system_category, "c6_0" ); + system_error c6_1( 1, system_category, "c6_1" ); + + TEST( c1_0, 0, "" ); + TEST( c1_1, 1, "Incorrect function" ); + TEST( c1_2u, 2, "The system cannot find the file specified" ); + + TEST( c2_0, 0, "c2_0" ); + TEST( c2_1, 1, "c2_1: Incorrect function" ); + + TEST( c3_0, 0, "c3_0" ); + TEST( c3_1, 1, "c3_1: Incorrect function" ); + + TEST( c4_0, 0, "" ); + TEST( c4_1, 1, "Incorrect function" ); + TEST( c4_2u, 2, "The system cannot find the file specified" ); + + TEST( c5_0, 0, "c5_0" ); + TEST( c5_1, 1, "c5_1: Incorrect function" ); + + TEST( c6_0, 0, "c6_0" ); + TEST( c6_1, 1, "c6_1: Incorrect function" ); return 0; }