未验证 提交 2b25367c 编写于 作者: K Kevin Heifner 提交者: GitHub

Merge pull request #2414 from EOSIO/2413

#2413 - Fix error message for refused connection not displayed properly
......@@ -46,9 +46,15 @@ namespace eosio { namespace client { namespace http {
endpoint_iterator = end;
} catch( std::exception& e ) {
++endpoint_iterator;
if( endpoint_iterator != end )
if( endpoint_iterator != end ) {
continue;
else throw;
} else {
throw connection_exception(fc::log_messages{
FC_LOG_MESSAGE( error, "Connection to ${server}:${port}${path} is refused",
("server", server)("port", port)("path", path) ),
FC_LOG_MESSAGE( error, e.what())
});
}
}
// Form the request. We specify the "Connection: close" header so that the
......
......@@ -46,4 +46,6 @@ namespace eosio { namespace client { namespace http {
const string wallet_unlock = wallet_func_base + "/unlock";
const string wallet_import_key = wallet_func_base + "/import_key";
const string wallet_sign_trx = wallet_func_base + "/sign_transaction";
FC_DECLARE_EXCEPTION( connection_exception, 1100000, "Connection Exception" );
}}}
\ No newline at end of file
......@@ -1159,9 +1159,8 @@ int main( int argc, char** argv ) {
return app.exit(e);
} catch (const explained_exception& e) {
return 1;
} catch (const fc::exception& e) {
} catch (connection_exception& e) {
auto errorString = e.to_detail_string();
if (errorString.find("Connection refused") != string::npos) {
if (errorString.find(fc::json::to_string(port)) != string::npos) {
std::cerr << localized("Failed to connect to nodeos at ${ip}:${port}; is nodeos running?", ("ip", host)("port", port)) << std::endl;
} else if (errorString.find(fc::json::to_string(wallet_port)) != string::npos) {
......@@ -1173,13 +1172,12 @@ int main( int argc, char** argv ) {
if (verbose_errors) {
elog("connect error: ${e}", ("e", errorString));
}
} else {
// attempt to extract the error code if one is present
if (!print_recognized_errors(e, verbose_errors)) {
// Error is not recognized
if (!print_help_text(e) || verbose_errors) {
elog("Failed with error: ${e}", ("e", verbose_errors ? e.to_detail_string() : e.to_string()));
}
} catch (const fc::exception& e) {
// attempt to extract the error code if one is present
if (!print_recognized_errors(e, verbose_errors)) {
// Error is not recognized
if (!print_help_text(e) || verbose_errors) {
elog("Failed with error: ${e}", ("e", verbose_errors ? e.to_detail_string() : e.to_string()));
}
}
return 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册