Fix error message printed when unable to deserialize a json object, improve

logging of return values and add logging of exceptional returns from
json function calls.  Continue my endless quest to break the mac build.
This commit is contained in:
Eric Frias 2014-05-06 17:20:04 -04:00
parent 3ac07ddbf5
commit b8a7531eab
4 changed files with 9 additions and 7 deletions

View file

@ -7,7 +7,7 @@ namespace fc {
namespace detail
{
NO_RETURN void throw_datastream_range_error( const char* file, size_t len, size_t over );
NO_RETURN void throw_datastream_range_error( const char* file, size_t len, int64_t over );
}
/**

View file

@ -1,7 +1,7 @@
#include <fc/io/datastream.hpp>
#include <fc/exception/exception.hpp>
NO_RETURN void fc::detail::throw_datastream_range_error(char const* method, size_t len, size_t over)
NO_RETURN void fc::detail::throw_datastream_range_error(char const* method, size_t len, int64_t over)
{
FC_THROW_EXCEPTION( out_of_range_exception, "${method} datastream of length ${len} over by ${over}", ("method",fc::string(method))("len",len)("over",over) );
}

View file

@ -110,19 +110,19 @@ namespace fc {
// This should work for modern Linuxes and for OSX >= Mountain Lion
int timeout_sec = interval.count() / fc::seconds(1).count();
if (setsockopt(my->_sock.native(), IPPROTO_TCP,
#if defined( __APPLE__ )
#if defined( __APPLE__ )
TCP_KEEPALIVE,
#else
TCP_KEEPIDLE,
#endif
(char*)&timeout_sec, sizeof(timeout_sec)) < 0)
wlog("Error setting TCP keepalive idle time");
#ifndef __APPLE__ // TCP_KEEPINTVL does not seem to work on 10.8.4
# if !defined(__APPLE__) || defined(TCP_KEEPINTVL) // TCP_KEEPINTVL not defined before 10.9
if (setsockopt(my->_sock.native(), IPPROTO_TCP, TCP_KEEPINTVL,
(char*)&timeout_sec, sizeof(timeout_sec)) < 0)
wlog("Error setting TCP keepalive interval");
#endif // !__APPLE__
#endif
# endif // !__APPLE__ || TCP_KEEPINTVL
#endif // !WIN32
}
else
{

View file

@ -35,7 +35,7 @@ namespace fc { namespace rpc {
void send_result( variant id, variant result )
{
ilog( "send ${i} ${r}", ("i",id)("r",result) );
ilog( "send: {\"id\": ${i}, \"result\": ${r}}", ("i",id)("r",result) );
{
fc::scoped_lock<fc::mutex> lock(_write_mutex);
*_out << "{\"id\":";
@ -48,6 +48,8 @@ namespace fc { namespace rpc {
}
void send_error( variant id, fc::exception& e )
{
ilog( "send: {\"id\": ${i}, \"error\":{\"message\": ${what},\"code\":0,\"data\":${data}}}",
("i",id)("what",e.what())("data", e) );
{
fc::scoped_lock<fc::mutex> lock(_write_mutex);
*_out << "{\"id\":";