From 82e1a690d97cd9d9f392beccbb6b1d35f3573f08 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Tue, 1 Dec 2009 14:24:55 +0000 Subject: Fixed directory renaming. --- tests/testUtils.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'tests/testUtils.cpp') diff --git a/tests/testUtils.cpp b/tests/testUtils.cpp index ee17c923..36455cff 100644 --- a/tests/testUtils.cpp +++ b/tests/testUtils.cpp @@ -187,3 +187,61 @@ vmime::ref testTimeoutHandlerFactory::create() return vmime::create (); } + + +// Exception helper +std::ostream& operator<<(std::ostream& os, const vmime::exception& e) +{ + os << "* vmime::exceptions::" << e.name() << std::endl; + os << " what = " << e.what() << std::endl; + + // More information for special exceptions + if (dynamic_cast (&e)) + { + const vmime::exceptions::command_error& cee = + dynamic_cast (e); + + os << " command = " << cee.command() << std::endl; + os << " response = " << cee.response() << std::endl; + } + + if (dynamic_cast (&e)) + { + const vmime::exceptions::invalid_response& ir = + dynamic_cast (e); + + os << " response = " << ir.response() << std::endl; + } + + if (dynamic_cast (&e)) + { + const vmime::exceptions::connection_greeting_error& cgee = + dynamic_cast (e); + + os << " response = " << cgee.response() << std::endl; + } + + if (dynamic_cast (&e)) + { + const vmime::exceptions::authentication_error& aee = + dynamic_cast (e); + + os << " response = " << aee.response() << std::endl; + } + + if (dynamic_cast (&e)) + { + const vmime::exceptions::filesystem_exception& fse = + dynamic_cast (e); + + os << " path = " << vmime::platform::getHandler()-> + getFileSystemFactory()->pathToString(fse.path()) << std::endl; + } + + if (e.other() != NULL) + os << *e.other(); + + return os; +} + + -- cgit v1.2.3