Add back separate message() function for getting the specific error string.

This commit is contained in:
chris 2003-09-27 03:13:25 +00:00
parent e2d71c2e57
commit c2dd23afd9
4 changed files with 16 additions and 5 deletions

View File

@ -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. /// Get the code associated with the error.
int code() const int code() const
{ {
@ -92,7 +103,7 @@ public:
} }
/// Get the message associated with the error. /// Get the message associated with the error.
virtual const char* what() const std::string message() const
{ {
if (message_.length() == 0) if (message_.length() == 0)
{ {
@ -116,7 +127,7 @@ public:
#endif #endif
} }
return message_.c_str(); return message_;
} }
/// Operator returns non-null if there is a non-success error code. /// Operator returns non-null if there is a non-success error code.

View File

@ -32,7 +32,7 @@ public:
{ {
if (error) if (error)
{ {
std::cout << "Accept error: " << error.what() << "\n"; std::cout << "Accept error: " << error.message() << "\n";
} }
else else
{ {

View File

@ -32,7 +32,7 @@ public:
{ {
if (error) if (error)
{ {
std::cout << "Connect error: " << error.what() << "\n"; std::cout << "Connect error: " << error.message() << "\n";
} }
else else
{ {

View File

@ -31,7 +31,7 @@ public:
{ {
if (error) if (error)
{ {
std::cout << "Receive error: " << error.what() << "\n"; std::cout << "Receive error: " << error.message() << "\n";
} }
else else
{ {