diff --git a/src/web/RPCServerHandler.h b/src/web/RPCServerHandler.h index 0c679be38..cc864fac4 100644 --- a/src/web/RPCServerHandler.h +++ b/src/web/RPCServerHandler.h @@ -19,16 +19,38 @@ #pragma once +#include "data/BackendInterface.h" #include "feed/SubscriptionManager.h" #include "rpc/Errors.h" #include "rpc/Factories.h" +#include "rpc/JS.h" #include "rpc/RPCHelpers.h" #include "rpc/common/impl/APIVersionParser.h" #include "util/JsonUtils.h" #include "util/Profiler.h" +#include "util/Taggable.h" +#include "util/config/Config.h" +#include "util/log/Logger.h" #include "web/impl/ErrorHandling.h" +#include "web/interface/ConnectionBase.h" +#include +#include +#include +#include #include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include namespace web { @@ -104,11 +126,13 @@ class RPCServerHandler { } catch (boost::system::system_error const& ex) { // system_error thrown when json parsing failed rpcEngine_->notifyBadSyntax(); - web::detail::ErrorHelper(connection).sendJsonParsingError(ex.what()); + web::detail::ErrorHelper(connection).sendJsonParsingError(); + LOG(log_.warn()) << "Error parsing JSON: " << ex.what() << ". For request: " << request; } catch (std::invalid_argument const& ex) { // thrown when json parses something that is not an object at top level rpcEngine_->notifyBadSyntax(); - web::detail::ErrorHelper(connection).sendJsonParsingError(ex.what()); + LOG(log_.warn()) << "Invalid argument error: " << ex.what() << ". For request: " << request; + web::detail::ErrorHelper(connection).sendJsonParsingError(); } catch (std::exception const& ex) { LOG(perfLog_.error()) << connection->tag() << "Caught exception: " << ex.what(); rpcEngine_->notifyInternalError(); diff --git a/src/web/impl/ErrorHandling.h b/src/web/impl/ErrorHandling.h index 048f18d73..a7f0a7649 100644 --- a/src/web/impl/ErrorHandling.h +++ b/src/web/impl/ErrorHandling.h @@ -23,12 +23,18 @@ #include "util/Assert.h" #include "web/interface/ConnectionBase.h" -#include -#include +#include +#include +#include +#include +#include #include #include #include +#include +#include +#include namespace web::detail { @@ -127,15 +133,13 @@ class ErrorHelper { } void - sendJsonParsingError(std::string_view reason) const + sendJsonParsingError() const { if (connection_->upgraded) { - connection_->send( - boost::json::serialize(rpc::makeError(rpc::RippledError::rpcBAD_SYNTAX)), boost::beast::http::status::ok - ); + connection_->send(boost::json::serialize(rpc::makeError(rpc::RippledError::rpcBAD_SYNTAX))); } else { connection_->send( - fmt::format("Unable to parse request: {}", reason), boost::beast::http::status::bad_request + fmt::format("Unable to parse JSON from the request"), boost::beast::http::status::bad_request ); } } diff --git a/src/web/impl/HttpBase.h b/src/web/impl/HttpBase.h index a7924ac91..330181165 100644 --- a/src/web/impl/HttpBase.h +++ b/src/web/impl/HttpBase.h @@ -21,6 +21,7 @@ #include "main/Build.h" #include "rpc/Errors.h" +#include "util/Taggable.h" #include "util/log/Logger.h" #include "util/prometheus/Http.h" #include "web/DOSGuard.h" @@ -28,13 +29,33 @@ #include "web/interface/Concepts.h" #include "web/interface/ConnectionBase.h" +#include +#include +#include #include +#include +#include #include +#include +#include +#include +#include +#include +#include #include +#include #include - +#include +#include +#include +#include + +#include +#include +#include #include #include +#include namespace web::detail { diff --git a/src/web/impl/WsBase.h b/src/web/impl/WsBase.h index 4dbde82e9..7dc9e26a9 100644 --- a/src/web/impl/WsBase.h +++ b/src/web/impl/WsBase.h @@ -19,17 +19,40 @@ #pragma once +#include "rpc/Errors.h" #include "rpc/common/Types.h" +#include "util/Taggable.h" #include "util/log/Logger.h" #include "web/DOSGuard.h" #include "web/interface/Concepts.h" #include "web/interface/ConnectionBase.h" +#include +#include #include -#include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include #include +#include +#include +#include namespace web::detail { @@ -153,7 +176,7 @@ class WsBase : public ConnectionBase, public std::enable_shared_from_this