Ubuntu 18.04 Upgrade #3
3 changed files with 12 additions and 7 deletions
|
|
@ -23,7 +23,10 @@ namespace fc { namespace rpc {
|
|||
response(){}
|
||||
response( int64_t i, fc::variant r ):id(i),result(r){}
|
||||
response( int64_t i, error_object r ):id(i),error(r){}
|
||||
response( int64_t i, fc::variant r, string j ):id(i),jsonrpc(j),result(r){}
|
||||
response( int64_t i, error_object r, string j ):id(i),jsonrpc(j),error(r){}
|
||||
int64_t id = 0;
|
||||
optional<fc::string> jsonrpc;
|
||||
optional<fc::variant> result;
|
||||
optional<error_object> error;
|
||||
};
|
||||
|
|
@ -57,4 +60,4 @@ namespace fc { namespace rpc {
|
|||
|
||||
FC_REFLECT( fc::rpc::request, (id)(method)(params) );
|
||||
FC_REFLECT( fc::rpc::error_object, (code)(message)(data) )
|
||||
FC_REFLECT( fc::rpc::response, (id)(result)(error) )
|
||||
FC_REFLECT( fc::rpc::response, (id)(jsonrpc)(result)(error) )
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ namespace fc
|
|||
* and other information that is generally only useful for
|
||||
* developers.
|
||||
*/
|
||||
string exception::to_detail_string( log_level ll )const
|
||||
string exception::to_detail_string( log_level ll )const
|
||||
{
|
||||
fc::stringstream ss;
|
||||
ss << variant(my->_code).as_string() <<" " << my->_name << ": " <<my->_what<<"\n";
|
||||
|
|
@ -173,13 +173,14 @@ namespace fc
|
|||
/**
|
||||
* Generates a user-friendly error report.
|
||||
*/
|
||||
string exception::to_string( log_level ll )const
|
||||
string exception::to_string( log_level ll )const
|
||||
{
|
||||
fc::stringstream ss;
|
||||
ss << what() << " (" << variant(my->_code).as_string() <<")\n";
|
||||
ss << what() << ":";
|
||||
for( auto itr = my->_elog.begin(); itr != my->_elog.end(); ++itr )
|
||||
{
|
||||
ss << fc::format_string( itr->get_format(), itr->get_data() ) <<"\n";
|
||||
if( itr->get_format().size() )
|
||||
ss << " " << fc::format_string( itr->get_format(), itr->get_data() );
|
||||
// ss << " " << itr->get_context().to_string() <<"\n";
|
||||
}
|
||||
return ss.str();
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ std::string websocket_api_connection::on_message(
|
|||
{
|
||||
auto var = fc::json::from_string(message);
|
||||
const auto& var_obj = var.get_object();
|
||||
|
||||
if( var_obj.contains( "method" ) )
|
||||
{
|
||||
auto call = var.as<fc::rpc::request>();
|
||||
|
|
@ -112,7 +113,7 @@ std::string websocket_api_connection::on_message(
|
|||
|
||||
if( call.id )
|
||||
{
|
||||
auto reply = fc::json::to_string( response( *call.id, result ) );
|
||||
auto reply = fc::json::to_string( response( *call.id, result, "2.0" ) );
|
||||
if( send_message )
|
||||
_connection.send_message( reply );
|
||||
return reply;
|
||||
|
|
@ -129,7 +130,7 @@ std::string websocket_api_connection::on_message(
|
|||
}
|
||||
if( optexcept ) {
|
||||
|
||||
auto reply = fc::json::to_string( response( *call.id, error_object{ 1, optexcept->to_detail_string(), fc::variant(*optexcept)} ) );
|
||||
auto reply = fc::json::to_string( response( *call.id, error_object{ 1, optexcept->to_string(), fc::variant(*optexcept)}, "2.0" ) );
|
||||
if( send_message )
|
||||
_connection.send_message( reply );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue