From c4c3ee2419252e6742b3c792c134ff12c512c8b5 Mon Sep 17 00:00:00 2001 From: Keke Li Date: Wed, 17 Feb 2021 12:56:30 -0800 Subject: [PATCH 1/3] Print error message received from server when json parser failed so as to easy understand what happened. --- programs/cleos/httpc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/programs/cleos/httpc.cpp b/programs/cleos/httpc.cpp index ecdb1541e15..3477f9535d8 100644 --- a/programs/cleos/httpc.cpp +++ b/programs/cleos/httpc.cpp @@ -258,6 +258,7 @@ namespace eosio { namespace client { namespace http { response_result = fc::json::from_string(re); } catch(...) { // re reported below if print_response requested + std::cerr << "Error happens, below is the message received from server:" << std::endl << re << std::endl; } if( print_response ) { From 1a9a384de149b587dc4fea70e69131b15491bf36 Mon Sep 17 00:00:00 2001 From: Keke Li Date: Wed, 17 Feb 2021 13:10:34 -0800 Subject: [PATCH 2/3] Print response when parse error happened. --- programs/cleos/httpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/programs/cleos/httpc.cpp b/programs/cleos/httpc.cpp index 3477f9535d8..1d3c7500010 100644 --- a/programs/cleos/httpc.cpp +++ b/programs/cleos/httpc.cpp @@ -258,7 +258,8 @@ namespace eosio { namespace client { namespace http { response_result = fc::json::from_string(re); } catch(...) { // re reported below if print_response requested - std::cerr << "Error happens, below is the message received from server:" << std::endl << re << std::endl; + std::cerr << "Error happens, below is the message received from server:" << std::endl; + print_response = true; } if( print_response ) { From 46c178dcb0592ee98d267143abceb7980df7f908 Mon Sep 17 00:00:00 2001 From: Keke Li Date: Wed, 17 Feb 2021 14:13:46 -0800 Subject: [PATCH 3/3] As this function is a common used function, and the exception maybe not an error. remove the error notice line. --- programs/cleos/httpc.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/programs/cleos/httpc.cpp b/programs/cleos/httpc.cpp index 1d3c7500010..f5b3514b75f 100644 --- a/programs/cleos/httpc.cpp +++ b/programs/cleos/httpc.cpp @@ -258,7 +258,6 @@ namespace eosio { namespace client { namespace http { response_result = fc::json::from_string(re); } catch(...) { // re reported below if print_response requested - std::cerr << "Error happens, below is the message received from server:" << std::endl; print_response = true; }