From 3b97064d40e93c26bdf895c52bedb2f58dda0406 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Tue, 4 Jan 2005 22:03:16 +0000 Subject: [PATCH] Added diagnostic error string for 'exceptions::connection_error' + fixed a bug in 'posixSocket::connect()' when specifying an IP address. --- ChangeLog | 7 +++++++ src/exception.cpp | 6 ++++-- src/messaging/maildirStore.cpp | 2 +- src/platforms/posix/posixSocket.cpp | 11 +++-------- vmime/exception.hpp | 2 +- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb781ef6..ee80502d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,13 @@ VERSION 0.6.2-cvs ================= +2005-01-04 Vincent Richard + + * Added diagnostic error string for 'exceptions::connection_error'. + + * Fixed a bug in 'posixSocket::connect()' that prevented connecting to + servers by specifying an IP address instead of a server name. + 2005-01-03 Vincent Richard * Fixed linking error on 'typeAdapter ::parse()' with g++ versions diff --git a/src/exception.cpp b/src/exception.cpp index fcb53900..cbdc3f3d 100644 --- a/src/exception.cpp +++ b/src/exception.cpp @@ -303,8 +303,10 @@ const string messaging_exception::name() const { return "messaging_exception"; } // connection_error::~connection_error() throw() {} -connection_error::connection_error(const exception& other) - : messaging_exception("Connection error.", other) {} +connection_error::connection_error(const string& what, const exception& other) + : messaging_exception(what.empty() + ? "Connection error." + : "Connection error: '" + what + "'.", other) {} exception* connection_error::clone() const { return new connection_error(*this); } const string connection_error::name() const { return "connection_error"; } diff --git a/src/messaging/maildirStore.cpp b/src/messaging/maildirStore.cpp index 63a94971..1bb5ace2 100644 --- a/src/messaging/maildirStore.cpp +++ b/src/messaging/maildirStore.cpp @@ -121,7 +121,7 @@ void maildirStore::connect() } catch (exceptions::filesystem_exception& e) { - throw exceptions::connection_error(e); + throw exceptions::connection_error("Cannot create root directory.", e); } } diff --git a/src/platforms/posix/posixSocket.cpp b/src/platforms/posix/posixSocket.cpp index 0318e553..39acf666 100644 --- a/src/platforms/posix/posixSocket.cpp +++ b/src/platforms/posix/posixSocket.cpp @@ -80,22 +80,17 @@ void posixSocket::connect(const vmime::string& address, const vmime::port_t port if (hostInfo == NULL) { // Error: cannot resolve address - throw vmime::exceptions::connection_error(); + throw vmime::exceptions::connection_error("Cannot resolve address."); } bcopy(hostInfo->h_addr, reinterpret_cast (&addr.sin_addr), hostInfo->h_length); } - else - { - // Error: cannot resolve address - throw vmime::exceptions::connection_error(); - } // Get a new socket m_desc = ::socket(AF_INET, SOCK_STREAM, 0); if (m_desc == -1) - throw vmime::exceptions::connection_error(); + throw vmime::exceptions::connection_error("Error while creating socket."); // Start connection if (::connect(m_desc, reinterpret_cast (&addr), sizeof(addr)) == -1) @@ -104,7 +99,7 @@ void posixSocket::connect(const vmime::string& address, const vmime::port_t port m_desc = -1; // Error - throw vmime::exceptions::connection_error(); + throw vmime::exceptions::connection_error("Error while connecting socket."); } } diff --git a/vmime/exception.hpp b/vmime/exception.hpp index d364a8e1..a251a064 100644 --- a/vmime/exception.hpp +++ b/vmime/exception.hpp @@ -326,7 +326,7 @@ class connection_error : public messaging_exception { public: - connection_error(const exception& other = NO_EXCEPTION); + connection_error(const string& what = "", const exception& other = NO_EXCEPTION); ~connection_error() throw(); exception* clone() const;