Author: loonycyborg
Date: Thu Jul 7 17:10:43 2011
New Revision: 50201
URL: http://svn.gna.org/viewcvs/wesnoth?rev=50201&view=rev
Log:
Reorganized exception handling.
Modified:
trunk/src/network_asio.cpp
trunk/src/network_asio.hpp
Modified: trunk/src/network_asio.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/network_asio.cpp?rev=50201&r1=50200&r2=50201&view=diff
==============================================================================
--- trunk/src/network_asio.cpp (original)
+++ trunk/src/network_asio.cpp Thu Jul 7 17:10:43 2011
@@ -23,6 +23,8 @@
namespace network_asio {
+using boost::system::system_error;
+
connection::connection(const std::string& host, const std::string& service)
: io_service_()
, resolver_(io_service_)
@@ -46,7 +48,7 @@
)
{
if(ec)
- throw error(ec);
+ throw system_error(ec);
std::cout << iterator->endpoint().address() << '\n';
connect(iterator);
@@ -67,7 +69,7 @@
if(ec) {
socket_.close();
if(++iterator == resolver::iterator())
- throw error(ec);
+ throw system_error(ec);
else
connect(iterator);
} else {
@@ -94,7 +96,7 @@
)
{
if(ec)
- throw error(ec);
+ throw system_error(ec);
done_ = true;
}
@@ -121,7 +123,7 @@
{
std::cout << "Written " << bytes_transferred << " bytes.\n";
if(ec)
- throw error(ec);
+ throw system_error(ec);
}
std::size_t connection::is_read_complete(
@@ -129,10 +131,8 @@
std::size_t bytes_transferred
)
{
- if(ec == boost::asio::error::operation_aborted)
- return 0;
if(ec)
- throw error(ec);
+ throw system_error(ec);
bytes_read_ = bytes_transferred;
if(bytes_transferred < 4) {
return 4;
@@ -160,10 +160,8 @@
std::cout << "Read " << bytes_transferred << " bytes.\n";
bytes_to_read_ = 0;
done_ = true;
- if(ec == boost::asio::error::operation_aborted)
- return;
if(ec && ec != boost::asio::error::eof)
- throw error(ec);
+ throw system_error(ec);
std::istream is(&read_buf_);
read_gz(response, is);
}
Modified: trunk/src/network_asio.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/network_asio.hpp?rev=50201&r1=50200&r2=50201&view=diff
==============================================================================
--- trunk/src/network_asio.hpp (original)
+++ trunk/src/network_asio.hpp Thu Jul 7 17:10:43 2011
@@ -98,6 +98,8 @@
try {
return io_service_.poll();
} catch(const boost::system::system_error& err) {
+ if(err.code() == boost::asio::error::operation_aborted)
+ return 1;
throw error(err.code());
}
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits