diff --git a/include/fc/time.hpp b/include/fc/time.hpp index 7f9678d..be2861c 100644 --- a/include/fc/time.hpp +++ b/include/fc/time.hpp @@ -12,6 +12,7 @@ namespace fc { bool operator==(const microseconds& c)const { return _count == c._count; } friend bool operator>(const microseconds& a, const microseconds& b){ return a._count > b._count; } + friend bool operator<(const microseconds& a, const microseconds& b){ return a._count < b._count; } microseconds& operator+=(const microseconds& c) { _count += c._count; return *this; } int64_t count()const { return _count; } private: diff --git a/src/http_connection.cpp b/src/http_connection.cpp index b9cfb1b..8ba1035 100644 --- a/src/http_connection.cpp +++ b/src/http_connection.cpp @@ -33,7 +33,7 @@ FC_START_SHARED_IMPL(fc::http::connection) fc::http::reply parse_reply() { fc::http::reply rep; - //try { + try { fc::vector line(1024*8); int s = read_until( line.data(), line.data()+line.size(), ' ' ); // HTTP/1.1 s = read_until( line.data(), line.data()+line.size(), ' ' ); // CODE @@ -56,16 +56,17 @@ FC_START_SHARED_IMPL(fc::http::connection) } } if( rep.body.size() ) { - slog( "Reading body size %d", rep.body.size() ); + //slog( "Reading body size %d", rep.body.size() ); sock.read( rep.body.data(), rep.body.size() ); } return rep; - /* } catch ( ... ) { + } catch ( ... ) { elog( "%s", fc::except_str().c_str() ); sock.close(); + FC_THROW_REPORT( "Error parsing reply" ); rep.status = http::reply::InternalServerError; return rep; - } */ + } } FC_END_SHARED_IMPL @@ -92,7 +93,7 @@ http::reply connection::request( const fc::string& method, wlog( "Re-open socket!" ); my->sock.connect_to( my->ep ); } - //try { + try { fc::stringstream req; req << method <<" "<parse_reply(); - // } catch ( ... ) { - // my->sock.close(); + } catch ( ... ) { + my->sock.close(); + FC_THROW_REPORT( "Error Sending HTTP Request" ); // TODO: provide more info // return http::reply( http::reply::InternalServerError ); // TODO: replace with connection error - // } + } } // used for servers diff --git a/src/tcp_socket.cpp b/src/tcp_socket.cpp index 541184a..c94f31e 100644 --- a/src/tcp_socket.cpp +++ b/src/tcp_socket.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -52,7 +53,9 @@ namespace fc { p->wait(); } else if( ec ) { elog( "throw... write data failed %s", boost::system::system_error(ec).what() ); - throw boost::system::system_error(ec); + FC_THROW_REPORT( "Failed to write data to tcp socket", + fc::value().set("reason", fc::string(boost::system::system_error(ec).what())) + .set("data", fc::to_hex(buf,len) ) ); } return *this; }