From c2dd23afd998b0485ba1407c4ac09998449f4e9e Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 27 Sep 2003 03:13:25 +0000 Subject: [PATCH] Add back separate message() function for getting the specific error string. --- asio/src/asio/socket_error.hpp | 15 +++++++++++++-- asio/src/tests/timed_accept_test.cpp | 2 +- asio/src/tests/timed_connect_test.cpp | 2 +- asio/src/tests/timed_dgram_recv_test.cpp | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/asio/src/asio/socket_error.hpp b/asio/src/asio/socket_error.hpp index 59bc5c13..b9a41dd2 100644 --- a/asio/src/asio/socket_error.hpp +++ b/asio/src/asio/socket_error.hpp @@ -85,6 +85,17 @@ public: { } + // Destructor. + virtual ~socket_error() throw () + { + } + + // Get the string for the type of exception. + virtual const char* what() const throw () + { + return "Socket error"; + } + /// Get the code associated with the error. int code() const { @@ -92,7 +103,7 @@ public: } /// Get the message associated with the error. - virtual const char* what() const + std::string message() const { if (message_.length() == 0) { @@ -116,7 +127,7 @@ public: #endif } - return message_.c_str(); + return message_; } /// Operator returns non-null if there is a non-success error code. diff --git a/asio/src/tests/timed_accept_test.cpp b/asio/src/tests/timed_accept_test.cpp index fe3aaa10..63531623 100644 --- a/asio/src/tests/timed_accept_test.cpp +++ b/asio/src/tests/timed_accept_test.cpp @@ -32,7 +32,7 @@ public: { if (error) { - std::cout << "Accept error: " << error.what() << "\n"; + std::cout << "Accept error: " << error.message() << "\n"; } else { diff --git a/asio/src/tests/timed_connect_test.cpp b/asio/src/tests/timed_connect_test.cpp index de2a99f0..638efa18 100644 --- a/asio/src/tests/timed_connect_test.cpp +++ b/asio/src/tests/timed_connect_test.cpp @@ -32,7 +32,7 @@ public: { if (error) { - std::cout << "Connect error: " << error.what() << "\n"; + std::cout << "Connect error: " << error.message() << "\n"; } else { diff --git a/asio/src/tests/timed_dgram_recv_test.cpp b/asio/src/tests/timed_dgram_recv_test.cpp index 9a1cee84..9219894a 100644 --- a/asio/src/tests/timed_dgram_recv_test.cpp +++ b/asio/src/tests/timed_dgram_recv_test.cpp @@ -31,7 +31,7 @@ public: { if (error) { - std::cout << "Receive error: " << error.what() << "\n"; + std::cout << "Receive error: " << error.message() << "\n"; } else {