Fix thread destruction in TestPeer and better exception reporting

This commit is contained in:
Vinnie Falco
2013-08-17 07:44:22 -07:00
parent 93f983ad71
commit 2333a38cd7
3 changed files with 34 additions and 0 deletions

View File

@@ -30,6 +30,13 @@ PeerTest::Result::Result (boost::system::error_code const& ec, String const& pre
{
}
PeerTest::Result::Result (std::exception const& e, String const& prefix)
: m_ec (TestPeerBasics::make_error (TestPeerBasics::errc::exceptioned))
, m_message ((prefix == String::empty) ? e.what ()
: prefix + ": " + e.what ())
{
}
bool PeerTest::Result::operator== (Result const& other) const noexcept
{
return m_ec == other.m_ec;

View File

@@ -49,6 +49,7 @@ public:
The prefix is prepended to the error message.
*/
explicit Result (boost::system::error_code const& ec, String const& prefix = "");
explicit Result (std::exception const& e, String const& prefix = "");
/** Returns true if the error codes match (message is ignored).
*/
@@ -143,30 +144,50 @@ public:
results.server = Result (ec, server.name ());
}
catch (std::exception& e)
{
results.server = Result (e, server.name ());
}
catch (...)
{
results.server = Result (TestPeerBasics::make_error (
TestPeerBasics::errc::exceptioned), server.name ());
}
}
catch (std::exception& e)
{
results.server = Result (e, client.name ());
}
catch (...)
{
results.client = Result (TestPeerBasics::make_error (
TestPeerBasics::errc::exceptioned), client.name ());
}
}
catch (std::exception& e)
{
results.server = Result (e, server.name ());
}
catch (...)
{
results.server = Result (TestPeerBasics::make_error (
TestPeerBasics::errc::exceptioned), server.name ());
}
}
catch (std::exception& e)
{
results.server = Result (e, "client");
}
catch (...)
{
results.client = Result (TestPeerBasics::make_error (
TestPeerBasics::errc::exceptioned), "client");
}
}
catch (std::exception& e)
{
results.server = Result (e, "server");
}
catch (...)
{
results.server = Result (TestPeerBasics::make_error (

View File

@@ -162,12 +162,18 @@ public:
error () = make_error (errc::timeout);
}
else
{
stopThread ();
}
}
else
{
// They requested an infinite wait.
//
m_join.wait ();
stopThread ();
}
}