From db12445b507f2216c2c5babb70fce570300b8f5e Mon Sep 17 00:00:00 2001 From: Alex Kremer Date: Tue, 8 Sep 2026 14:45:42 +0100 Subject: [PATCH] refactor: Use error types from rpc-spec (#3173) --- conan.lock | 2 +- conanfile.py | 2 +- src/app/WebHandlers.cpp | 1 + src/etl/CMakeLists.txt | 2 +- src/etl/LoadBalancer.cpp | 4 +- src/etl/Source.hpp | 2 +- src/etl/impl/ForwardingSource.cpp | 12 +- src/etl/impl/ForwardingSource.hpp | 2 +- src/etl/impl/SourceImpl.hpp | 2 +- src/feed/CMakeLists.txt | 2 +- src/rpc/CredentialHelpers.cpp | 2 +- src/rpc/Errors.cpp | 190 ++++++------ src/rpc/Errors.hpp | 285 +----------------- src/rpc/Factories.cpp | 2 +- src/rpc/RPCHelpers.cpp | 2 +- src/rpc/common/AnyHandler.hpp | 2 +- src/rpc/common/MetaProcessors.cpp | 2 +- src/rpc/common/Specs.cpp | 2 +- src/rpc/common/Specs.hpp | 4 +- src/rpc/common/Validators.cpp | 2 +- src/rpc/handlers/AMMInfo.cpp | 2 +- src/rpc/handlers/AccountChannels.cpp | 2 +- src/rpc/handlers/AccountCurrencies.cpp | 2 +- src/rpc/handlers/AccountInfo.cpp | 2 +- src/rpc/handlers/AccountLines.cpp | 2 +- src/rpc/handlers/AccountMPTokenIssuances.cpp | 2 +- src/rpc/handlers/AccountMPTokens.cpp | 2 +- src/rpc/handlers/AccountNFTs.cpp | 2 +- src/rpc/handlers/AccountObjects.cpp | 2 +- src/rpc/handlers/AccountOffers.cpp | 2 +- src/rpc/handlers/AccountTx.cpp | 2 +- src/rpc/handlers/DepositAuthorized.cpp | 2 +- src/rpc/handlers/Feature.cpp | 2 +- src/rpc/handlers/GatewayBalances.cpp | 2 +- src/rpc/handlers/GetAggregatePrice.cpp | 1 - src/rpc/handlers/LedgerData.cpp | 2 +- src/rpc/handlers/LedgerEntry.cpp | 2 +- src/rpc/handlers/LedgerIndex.cpp | 2 +- src/rpc/handlers/MPTHolders.cpp | 2 +- src/rpc/handlers/MPTokenIssuanceHistory.cpp | 2 +- src/rpc/handlers/NFTHistory.cpp | 2 +- src/rpc/handlers/NFTInfo.cpp | 2 +- src/rpc/handlers/NFTOffersCommon.cpp | 2 +- src/rpc/handlers/NFTsByIssuer.cpp | 2 +- src/rpc/handlers/NoRippleCheck.cpp | 2 +- src/rpc/handlers/Subscribe.cpp | 2 +- src/rpc/handlers/TransactionEntry.cpp | 2 +- src/rpc/handlers/Unsubscribe.cpp | 2 +- src/rpc/handlers/VaultInfo.cpp | 2 +- src/web/CMakeLists.txt | 2 +- src/web/impl/ErrorHandling.hpp | 8 +- src/web/ng/impl/ErrorHandling.cpp | 9 +- tests/common/util/MockSource.hpp | 2 +- tests/unit/app/WebHandlersTests.cpp | 2 +- tests/unit/etl/ETLStateTests.cpp | 4 +- tests/unit/etl/ForwardingSourceTests.cpp | 14 +- tests/unit/etl/LoadBalancerTests.cpp | 46 +-- tests/unit/etl/SourceImplTests.cpp | 2 +- tests/unit/rpc/BaseTests.cpp | 2 +- tests/unit/rpc/ErrorTests.cpp | 7 +- tests/unit/rpc/ForwardingProxyTests.cpp | 6 +- tests/unit/rpc/RPCEngineTests.cpp | 2 +- tests/unit/rpc/RPCHelpersTests.cpp | 1 + tests/unit/rpc/common/CheckersTests.cpp | 2 +- tests/unit/rpc/common/SpecsTests.cpp | 2 +- tests/unit/rpc/common/TypesTests.cpp | 1 - .../rpc/handlers/AccountCurrenciesTests.cpp | 1 + tests/unit/rpc/handlers/AccountInfoTests.cpp | 1 + tests/unit/rpc/handlers/AccountLinesTests.cpp | 1 + .../unit/rpc/handlers/AccountOffersTests.cpp | 1 + .../rpc/handlers/CredentialHelpersTests.cpp | 2 +- tests/unit/rpc/handlers/LedgerDataTests.cpp | 1 + tests/unit/rpc/handlers/LedgerEntryTests.cpp | 1 + tests/unit/rpc/handlers/LedgerTests.cpp | 1 + tests/unit/rpc/handlers/ServerInfoTests.cpp | 9 +- tests/unit/rpc/handlers/SubscribeTests.cpp | 1 + tests/unit/rpc/handlers/TestHandlerTests.cpp | 1 + tests/unit/rpc/handlers/TxTests.cpp | 1 + tests/unit/rpc/handlers/UnsubscribeTests.cpp | 1 + tests/unit/rpc/handlers/VaultInfoTests.cpp | 1 + tests/unit/web/LoadWarningTests.cpp | 2 +- tests/unit/web/RPCServerHandlerTests.cpp | 22 +- tests/unit/web/impl/ErrorHandlingTests.cpp | 2 +- tests/unit/web/ng/RPCServerHandlerTests.cpp | 2 +- tests/unit/web/ng/impl/ErrorHandlingTests.cpp | 2 +- 85 files changed, 250 insertions(+), 496 deletions(-) diff --git a/conan.lock b/conan.lock index c0a1fcd70..a599de081 100644 --- a/conan.lock +++ b/conan.lock @@ -3,7 +3,7 @@ "requires": [ "zlib/1.3.2#1cb806da49011867778ffb6ac7190fcb%1782392402.122708", "xxhash/0.8.3#681d36a0a6111fc56e5e45ea182c19cc%1782392402.420688", - "xrpl-rpc-spec/0.1.6#0147dce06088874791dca62dc8503b6c%1787751048.16847", + "xrpl-rpc-spec/0.1.7#774d2f93c4b48a1523d8d5a94a2b082a%1787768955.574105", "xrpl/3.3.0#5e356a24ae1f0d6da6bd617b926f92e6%1786467262.262007", "sqlite3/3.53.0#324ada52333108388a9a6108bfa96734%1782392403.185447", "spdlog/1.17.0#bcbaaf7147bda6ad24ffbd1ac3d7142c%1782736610.443882", diff --git a/conanfile.py b/conanfile.py index 3ef0797cf..056f092b2 100644 --- a/conanfile.py +++ b/conanfile.py @@ -17,7 +17,7 @@ class ClioConan(ConanFile): "fmt/12.1.0", "libbacktrace/cci.20210118", "spdlog/1.17.0", - "xrpl-rpc-spec/0.1.6", + "xrpl-rpc-spec/0.1.7", "xrpl/3.3.0", ] diff --git a/src/app/WebHandlers.cpp b/src/app/WebHandlers.cpp index dce06c412..a320927b5 100644 --- a/src/app/WebHandlers.cpp +++ b/src/app/WebHandlers.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include diff --git a/src/etl/CMakeLists.txt b/src/etl/CMakeLists.txt index 17cabe312..89ff92894 100644 --- a/src/etl/CMakeLists.txt +++ b/src/etl/CMakeLists.txt @@ -29,4 +29,4 @@ target_sources( impl/ext/Successor.cpp ) -target_link_libraries(clio_etl PUBLIC clio_data clio_util) +target_link_libraries(clio_etl PUBLIC clio_data clio_util rpcspec::rpcspec) diff --git a/src/etl/LoadBalancer.cpp b/src/etl/LoadBalancer.cpp index 9bb14b777..e2c42cf8f 100644 --- a/src/etl/LoadBalancer.cpp +++ b/src/etl/LoadBalancer.cpp @@ -7,7 +7,6 @@ #include "etl/NetworkValidatedLedgersInterface.hpp" #include "etl/Source.hpp" #include "feed/SubscriptionManagerInterface.hpp" -#include "rpc/Errors.hpp" #include "util/Assert.hpp" #include "util/CoroutineGroup.hpp" #include "util/Profiler.hpp" @@ -27,6 +26,7 @@ #include #include #include +#include #include #include @@ -292,7 +292,7 @@ LoadBalancer::forwardToRippled( auto xUserValue = isAdmin ? kAdminForwardingXUserValue : kUserForwardingXUserValue; std::optional response; - rpc::ClioError error = rpc::ClioError::EtlConnectionError; + rpc::ClioError error = rpc::ClioError::RpcForwardingConnectionError; while (numAttempts < sources_.size()) { auto [res, duration] = util::timed([&]() { return sources_[sourceIdx]->forwardToRippled(request, clientIp, xUserValue, yield); diff --git a/src/etl/Source.hpp b/src/etl/Source.hpp index ca7acb9b8..7118e31fc 100644 --- a/src/etl/Source.hpp +++ b/src/etl/Source.hpp @@ -4,7 +4,6 @@ #include "etl/LoadBalancerInterface.hpp" #include "etl/NetworkValidatedLedgersInterface.hpp" #include "feed/SubscriptionManagerInterface.hpp" -#include "rpc/Errors.hpp" #include "util/config/ObjectView.hpp" #include @@ -13,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/src/etl/impl/ForwardingSource.cpp b/src/etl/impl/ForwardingSource.cpp index 1ea8512ef..2b4115471 100644 --- a/src/etl/impl/ForwardingSource.cpp +++ b/src/etl/impl/ForwardingSource.cpp @@ -1,6 +1,5 @@ #include "etl/impl/ForwardingSource.hpp" -#include "rpc/Errors.hpp" #include "util/log/Logger.hpp" #include @@ -10,6 +9,7 @@ #include #include #include +#include #include #include @@ -58,14 +58,14 @@ ForwardingSource::forwardToRippled( auto expectedConnection = connectionBuilder.connect(yield); if (not expectedConnection) { LOG(log_.debug()) << "Couldn't connect to rippled to forward request."; - return std::unexpected{rpc::ClioError::EtlConnectionError}; + return std::unexpected{rpc::ClioError::RpcForwardingConnectionError}; } auto& connection = expectedConnection.value(); auto writeError = connection->write(boost::json::serialize(request), yield, forwardingTimeout_); if (writeError) { LOG(log_.debug()) << "Error sending request to rippled to forward request."; - return std::unexpected{rpc::ClioError::EtlRequestError}; + return std::unexpected{rpc::ClioError::RpcForwardingRequestError}; } auto response = connection->read(yield, forwardingTimeout_); @@ -73,10 +73,10 @@ ForwardingSource::forwardToRippled( if (auto errorCode = response.error().errorCode(); errorCode.has_value() and errorCode->value() == boost::system::errc::timed_out) { LOG(log_.debug()) << "Request to rippled timed out"; - return std::unexpected{rpc::ClioError::EtlRequestTimeout}; + return std::unexpected{rpc::ClioError::RpcForwardingTimeout}; } LOG(log_.debug()) << "Error sending request to rippled to forward request."; - return std::unexpected{rpc::ClioError::EtlRequestError}; + return std::unexpected{rpc::ClioError::RpcForwardingRequestError}; } boost::json::value parsedResponse; @@ -87,7 +87,7 @@ ForwardingSource::forwardToRippled( } catch (std::exception const& e) { LOG(log_.debug()) << "Error parsing response from rippled: " << e.what() << ". Response: " << *response; - return std::unexpected{rpc::ClioError::EtlInvalidResponse}; + return std::unexpected{rpc::ClioError::RpcForwardingInvalidResponse}; } auto responseObject = parsedResponse.as_object(); diff --git a/src/etl/impl/ForwardingSource.hpp b/src/etl/impl/ForwardingSource.hpp index 3806b9b71..d86e3a312 100644 --- a/src/etl/impl/ForwardingSource.hpp +++ b/src/etl/impl/ForwardingSource.hpp @@ -1,11 +1,11 @@ #pragma once -#include "rpc/Errors.hpp" #include "util/log/Logger.hpp" #include "util/requests/WsConnection.hpp" #include #include +#include #include #include diff --git a/src/etl/impl/SourceImpl.hpp b/src/etl/impl/SourceImpl.hpp index 211c65d11..790c2fba6 100644 --- a/src/etl/impl/SourceImpl.hpp +++ b/src/etl/impl/SourceImpl.hpp @@ -6,12 +6,12 @@ #include "etl/impl/ForwardingSource.hpp" #include "etl/impl/GrpcSource.hpp" #include "etl/impl/SubscriptionSource.hpp" -#include "rpc/Errors.hpp" #include #include #include #include +#include #include #include diff --git a/src/feed/CMakeLists.txt b/src/feed/CMakeLists.txt index e136caca8..acfd1361c 100644 --- a/src/feed/CMakeLists.txt +++ b/src/feed/CMakeLists.txt @@ -9,4 +9,4 @@ target_sources( impl/SingleFeedBase.cpp ) -target_link_libraries(clio_feed PRIVATE clio_util) +target_link_libraries(clio_feed PRIVATE clio_util rpcspec::rpcspec) diff --git a/src/rpc/CredentialHelpers.cpp b/src/rpc/CredentialHelpers.cpp index 2601cb03e..f89f904f1 100644 --- a/src/rpc/CredentialHelpers.cpp +++ b/src/rpc/CredentialHelpers.cpp @@ -1,5 +1,4 @@ #include "data/BackendInterface.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/common/Types.hpp" #include "util/Assert.hpp" @@ -7,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/Errors.cpp b/src/rpc/Errors.cpp index f8ec37cfa..c0c3b0ea5 100644 --- a/src/rpc/Errors.cpp +++ b/src/rpc/Errors.cpp @@ -4,10 +4,12 @@ #include "util/OverloadSet.hpp" #include +#include #include #include #include +#include #include #include #include @@ -22,6 +24,16 @@ using namespace std; namespace rpc { +/** + * @brief Stream a Status in human readable form. + * + * Declared in rpcspec but implemented here: rendering a code needs Clio's + * getErrorInfo table and xrpl::RPC::getErrorInfo. + * + * @param stream The stream to write to + * @param status The status to write + * @return The same stream + */ std::ostream& operator<<(std::ostream& stream, Status const& status) { @@ -57,100 +69,100 @@ operator<<(std::ostream& stream, Status const& status) return stream; } -WarningInfo const& -getWarningInfo(WarningCode code) -{ - static constexpr WarningInfo kInfos[]{ - {WarningCode::WarnUnknown, "Unknown warning"}, - {WarningCode::WarnRpcClio, - "This is a clio server. clio only serves validated data. If you want to talk to rippled, " - "include " - "'ledger_index':'current' in your request"}, - {WarningCode::WarnRpcOutdated, "This server may be out of date"}, - {WarningCode::WarnRpcRateLimit, "You are about to be rate limited"}, - {WarningCode::WarnRpcDeprecated, - "Some fields from your request are deprecated. Please check the documentation at " - "https://xrpl.org/docs/references/http-websocket-apis/ and update your request."} - }; - - auto matchByCode = [code](auto const& info) { return info.code == code; }; - if (auto it = ranges::find_if(kInfos, matchByCode); it != end(kInfos)) - return *it; - - throw(out_of_range("Invalid WarningCode")); -} - -boost::json::object -makeWarning(WarningCode code) -{ - auto json = boost::json::object{}; - auto const& info = getWarningInfo(code); - json["id"] = static_cast(code); - json["message"] = info.message; - return json; -} - ClioErrorInfo const& getErrorInfo(ClioError code) { - static constexpr ClioErrorInfo kInfos[]{ - {.code = ClioError::RpcMalformedCurrency, - .error = "malformedCurrency", - .message = "Malformed currency."}, - {.code = ClioError::RpcMalformedRequest, - .error = "malformedRequest", - .message = "Malformed request."}, - {.code = ClioError::RpcMalformedOwner, - .error = "malformedOwner", - .message = "Malformed owner."}, - {.code = ClioError::RpcMalformedAddress, - .error = "malformedAddress", - .message = "Malformed address."}, - {.code = ClioError::RpcUnknownOption, - .error = "unknownOption", - .message = "Unknown option."}, - {.code = ClioError::RpcFieldNotFoundTransaction, - .error = "fieldNotFoundTransaction", - .message = "Missing field."}, - {.code = ClioError::RpcMalformedOracleDocumentId, - .error = "malformedDocumentID", - .message = "Malformed oracle_document_id."}, - {.code = ClioError::RpcMalformedAuthorizedCredentials, - .error = "malformedAuthorizedCredentials", - .message = "Malformed authorized credentials."}, + static constexpr auto kInfos = std::to_array({ + { + .code = ClioError::RpcMalformedCurrency, + .error = "malformedCurrency", + .message = "Malformed currency.", + }, + { + .code = ClioError::RpcMalformedRequest, + .error = "malformedRequest", + .message = "Malformed request.", + }, + { + .code = ClioError::RpcMalformedOwner, + .error = "malformedOwner", + .message = "Malformed owner.", + }, + { + .code = ClioError::RpcMalformedAddress, + .error = "malformedAddress", + .message = "Malformed address.", + }, + { + .code = ClioError::RpcUnknownOption, + .error = "unknownOption", + .message = "Unknown option.", + }, + { + .code = ClioError::RpcFieldNotFoundTransaction, + .error = "fieldNotFoundTransaction", + .message = "Missing field.", + }, + { + .code = ClioError::RpcMalformedOracleDocumentId, + .error = "malformedDocumentID", + .message = "Malformed oracle_document_id.", + }, + { + .code = ClioError::RpcMalformedAuthorizedCredentials, + .error = "malformedAuthorizedCredentials", + .message = "Malformed authorized credentials.", + }, // special system errors - {.code = ClioError::RpcInvalidApiVersion, - .error = JS(invalid_API_version), - .message = "Invalid API version."}, - {.code = ClioError::RpcCommandIsMissing, - .error = JS(missingCommand), - .message = "Method is not specified or is not a string."}, - {.code = ClioError::RpcCommandNotString, - .error = "commandNotString", - .message = "Method is not a string."}, - {.code = ClioError::RpcCommandIsEmpty, - .error = "emptyCommand", - .message = "Method is an empty string."}, - {.code = ClioError::RpcParamsUnparsable, - .error = "paramsUnparsable", - .message = "Params must be an array holding exactly one object."}, - // etl related errors - {.code = ClioError::EtlConnectionError, - .error = "connectionError", - .message = "Couldn't connect to rippled."}, - {.code = ClioError::EtlRequestError, - .error = "requestError", - .message = "Error sending request to rippled."}, - {.code = ClioError::EtlRequestTimeout, - .error = "timeout", - .message = "Request to rippled timed out."}, - {.code = ClioError::EtlInvalidResponse, - .error = "invalidResponse", - .message = "Rippled returned an invalid response."} - }; + { + .code = ClioError::RpcInvalidApiVersion, + .error = JS(invalid_API_version), + .message = "Invalid API version.", + }, + { + .code = ClioError::RpcCommandIsMissing, + .error = JS(missingCommand), + .message = "Method is not specified or is not a string.", + }, + { + .code = ClioError::RpcCommandNotString, + .error = "commandNotString", + .message = "Method is not a string.", + }, + { + .code = ClioError::RpcCommandIsEmpty, + .error = "emptyCommand", + .message = "Method is an empty string.", + }, + { + .code = ClioError::RpcParamsUnparsable, + .error = "paramsUnparsable", + .message = "Params must be an array holding exactly one object.", + }, + // errors from forwarding to an upstream rippled source + { + .code = ClioError::RpcForwardingConnectionError, + .error = "connectionError", + .message = "Couldn't connect to rippled.", + }, + { + .code = ClioError::RpcForwardingRequestError, + .error = "requestError", + .message = "Error sending request to rippled.", + }, + { + .code = ClioError::RpcForwardingTimeout, + .error = "timeout", + .message = "Request to rippled timed out.", + }, + { + .code = ClioError::RpcForwardingInvalidResponse, + .error = "invalidResponse", + .message = "Rippled returned an invalid response.", + }, + }); - auto matchByCode = [code](auto const& info) { return info.code == code; }; - if (auto it = ranges::find_if(kInfos, matchByCode); it != end(kInfos)) + if (auto it = ranges::find(kInfos, code, &ClioErrorInfo::code); it != end(kInfos)) return *it; throw(out_of_range("Invalid error code")); diff --git a/src/rpc/Errors.hpp b/src/rpc/Errors.hpp index 5b06c365a..c5bb2e3f9 100644 --- a/src/rpc/Errors.hpp +++ b/src/rpc/Errors.hpp @@ -2,51 +2,15 @@ #pragma once #include -#include +#include -#include #include -#include #include -#include -#include namespace rpc { /** - * @brief Custom clio RPC Errors. - */ -enum class ClioError { - // normal clio errors start with 5000 - RpcMalformedCurrency = 5000, - RpcMalformedRequest = 5001, - RpcMalformedOwner = 5002, - RpcMalformedAddress = 5003, - RpcUnknownOption = 5005, - RpcFieldNotFoundTransaction = 5006, - RpcMalformedOracleDocumentId = 5007, - RpcMalformedAuthorizedCredentials = 5008, - // NOTE: RpcEntryNotFound is replaced with RippledError::RpcEntryNotFound - // RpcEntryNotFound = 5009, - - // special system errors start with 6000 - RpcInvalidApiVersion = 6000, - RpcCommandIsMissing = 6001, - RpcCommandNotString = 6002, - RpcCommandIsEmpty = 6003, - RpcParamsUnparsable = 6004, - - // TODO: Since it is not only rpc errors here now, we should move it to util - // etl related errors start with 7000 - // Higher value in this errors means better progress in the forwarding - EtlConnectionError = 7000, - EtlRequestError = 7001, - EtlRequestTimeout = 7002, - EtlInvalidResponse = 7003, -}; - -/** - * @brief Holds info about a particular @ref ClioError. + * @brief Holds info about a particular ClioError. */ struct ClioErrorInfo { ClioError const code; @@ -55,238 +19,10 @@ struct ClioErrorInfo { }; /** - * @brief Clio uses compatible Rippled error codes for most RPC errors. - */ -using RippledError = xrpl::ErrorCodeI; - -/** - * @brief Clio operates on a combination of Rippled and Custom Clio error codes. - * - * @see RippledError For rippled error codes - * @see ClioError For custom clio error codes - */ -using CombinedError = std::variant; - -/** - * @brief A status returned from any RPC handler. - */ -struct Status { - CombinedError code = RippledError::RpcSuccess; - std::string error; - std::string message; - std::optional extraInfo; - - Status() = default; - - /** - * @brief Construct a new Status object - * - * @param code The error code - */ - /* implicit */ Status(CombinedError code) : code(code) {}; - - /** - * @brief Construct a new Status object - * - * @param code The error code - * @param extraInfo The extra info - */ - Status(CombinedError code, boost::json::object&& extraInfo) - : code(code), extraInfo(std::move(extraInfo)) {}; - - /** - * @brief Construct a new Status object with a custom message - * - * @note HACK. Some rippled handlers explicitly specify errors. This means that we have to be - * able to duplicate this functionality. - * - * @param message The message - */ - explicit Status(std::string message) : code(xrpl::RpcUnknown), message(std::move(message)) - { - } - - /** - * @brief Construct a new Status object - * - * @param code The error code - * @param message The message - */ - Status(CombinedError code, std::string message) : code(code), message(std::move(message)) - { - } - - /** - * @brief Construct a new Status object - * - * @param code The error code - * @param error The error - * @param message The message - */ - Status(CombinedError code, std::string error, std::string message) - : code(code), error(std::move(error)), message(std::move(message)) - { - } - - bool - operator==(Status const& other) const = default; - - /** - * @brief Check if the status is not OK - * - * @return true if the status is not OK; false otherwise - */ - operator bool() const - { - if (auto err = std::get_if(&code)) - return *err != RippledError::RpcSuccess; - - return true; - } - - /** - * @brief Returns true if the @ref rpc::Status contains the desired @ref rpc::RippledError - * - * @param other The @ref rpc::RippledError to match - * @return true if status matches given error; false otherwise - */ - bool - operator==(RippledError other) const - { - if (auto err = std::get_if(&code)) - return *err == other; - - return false; - } - - /** - * @brief Returns true if the Status contains the desired @ref ClioError - * - * @param other The RippledError to match - * @return true if status matches given error; false otherwise - */ - bool - operator==(ClioError other) const - { - if (auto err = std::get_if(&code)) - return *err == other; - - return false; - } - - /** - * @brief Custom output stream for Status - * - * @param stream The output stream - * @param status The Status - * @return The same ostream we were given - */ - friend std::ostream& - operator<<(std::ostream& stream, Status const& status); -}; - -/** - * @brief Warning codes that can be returned by clio. - */ -// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) -enum WarningCode { - WarnUnknown = -1, - WarnRpcClio = 2001, - WarnRpcOutdated = 2002, - WarnRpcRateLimit = 2003, - WarnRpcDeprecated = 2004 -}; - -/** - * @brief Holds information about a clio warning. - */ -struct WarningInfo { - constexpr WarningInfo() = default; - - /** - * @brief Construct a new Warning Info object - * - * @param code The warning code - * @param message The warning message - */ - constexpr WarningInfo(WarningCode code, char const* message) : code(code), message(message) - { - } - - WarningCode code = WarningCode::WarnUnknown; - std::string_view const message = "unknown warning"; -}; - -/** - * @brief Invalid parameters error. - */ -class InvalidParamsError : public std::exception { - std::string msg_; - -public: - /** - * @brief Construct a new Invalid Params Error object - * - * @param msg The error message - */ - explicit InvalidParamsError(std::string msg) : msg_(std::move(msg)) - { - } - - /** - * @brief Get the error message as a C string - * - * @return The error message - */ - [[nodiscard]] char const* - what() const noexcept override - { - return msg_.c_str(); - } -}; - -/** - * @brief Account not found error. - */ -class AccountNotFoundError : public std::exception { - std::string account_; - -public: - /** - * @brief Construct a new Account Not Found Error object - * - * @param acct The account - */ - explicit AccountNotFoundError(std::string acct) : account_(std::move(acct)) - { - } - - /** - * @brief Get the error message as a C string - * - * @return The error message - */ - [[nodiscard]] char const* - what() const noexcept override - { - return account_.c_str(); - } -}; - -/** - * @brief A globally available @ref rpc::Status that represents a successful state. + * @brief A globally available rpc::Status that represents a successful state. */ static Status gOk; -/** - * @brief Get the warning info object from a warning code. - * - * @param code The warning code - * @return A reference to the static warning info - */ -WarningInfo const& -getWarningInfo(WarningCode code); - /** * @brief Get the error info object from an clio-specific error code. * @@ -297,16 +33,7 @@ ClioErrorInfo const& getErrorInfo(ClioError code); /** - * @brief Generate JSON from a @ref rpc::WarningCode. - * - * @param code The warning code - * @return The JSON output - */ -boost::json::object -makeWarning(WarningCode code); - -/** - * @brief Generate JSON from a @ref rpc::Status. + * @brief Generate JSON from a rpc::Status. * * @param status The status object * @return The JSON output @@ -315,7 +42,7 @@ boost::json::object makeError(Status const& status); /** - * @brief Generate JSON from a @ref rpc::RippledError. + * @brief Generate JSON from a rpc::RippledError. * * @param err The rippled error * @param customError A custom error @@ -330,7 +57,7 @@ makeError( ); /** - * @brief Generate JSON from a @ref rpc::ClioError. + * @brief Generate JSON from a rpc::ClioError. * * @param err The clio's custom error * @param customError A custom error diff --git a/src/rpc/Factories.cpp b/src/rpc/Factories.cpp index 6badd0147..22c4aa996 100644 --- a/src/rpc/Factories.cpp +++ b/src/rpc/Factories.cpp @@ -1,7 +1,6 @@ #include "rpc/Factories.hpp" #include "data/Types.hpp" -#include "rpc/Errors.hpp" #include "rpc/common/APIVersion.hpp" #include "rpc/common/Types.hpp" #include "util/Taggable.hpp" @@ -13,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/src/rpc/RPCHelpers.cpp b/src/rpc/RPCHelpers.cpp index c75e1fef3..2c95a64e1 100644 --- a/src/rpc/RPCHelpers.cpp +++ b/src/rpc/RPCHelpers.cpp @@ -4,7 +4,6 @@ #include "data/AmendmentCenterInterface.hpp" #include "data/BackendInterface.hpp" #include "data/Types.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/common/Types.hpp" #include "util/AccountUtils.hpp" @@ -27,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/common/AnyHandler.hpp b/src/rpc/common/AnyHandler.hpp index 3c305d080..c818a2e2c 100644 --- a/src/rpc/common/AnyHandler.hpp +++ b/src/rpc/common/AnyHandler.hpp @@ -60,7 +60,7 @@ public: * * @param value The JSON to process * @param ctx Request context - * @return JSON result or @ref Status on error + * @return JSON result or Status on error */ [[nodiscard]] ReturnType process(boost::json::value const& value, Context const& ctx) const diff --git a/src/rpc/common/MetaProcessors.cpp b/src/rpc/common/MetaProcessors.cpp index a5ab8cc7c..6b6155d25 100644 --- a/src/rpc/common/MetaProcessors.cpp +++ b/src/rpc/common/MetaProcessors.cpp @@ -1,9 +1,9 @@ #include "rpc/common/MetaProcessors.hpp" -#include "rpc/Errors.hpp" #include "rpc/common/Types.hpp" #include +#include #include diff --git a/src/rpc/common/Specs.cpp b/src/rpc/common/Specs.cpp index c837efead..ab0919265 100644 --- a/src/rpc/common/Specs.cpp +++ b/src/rpc/common/Specs.cpp @@ -1,11 +1,11 @@ #include "rpc/common/Specs.hpp" -#include "rpc/Errors.hpp" #include "rpc/common/Checkers.hpp" #include "rpc/common/Types.hpp" #include #include +#include #include #include diff --git a/src/rpc/common/Specs.hpp b/src/rpc/common/Specs.hpp index f3996da37..5a5e6eaa7 100644 --- a/src/rpc/common/Specs.hpp +++ b/src/rpc/common/Specs.hpp @@ -54,7 +54,7 @@ struct FieldSpec final { * @brief Processes the passed JSON value using the stored processors. * * @param value The JSON value to validate and/or modify - * @return Nothing on success; @ref Status on error + * @return Nothing on success; Status on error */ [[nodiscard]] MaybeError process(boost::json::value& value) const; @@ -106,7 +106,7 @@ struct RpcSpec final { * @brief Processes the passed JSON value using the stored field specs. * * @param value The JSON value to validate and/or modify - * @return Nothing on success; @ref Status on error + * @return Nothing on success; Status on error */ [[nodiscard]] MaybeError process(boost::json::value& value) const; diff --git a/src/rpc/common/Validators.cpp b/src/rpc/common/Validators.cpp index 1cd86e8e6..1a0f74374 100644 --- a/src/rpc/common/Validators.cpp +++ b/src/rpc/common/Validators.cpp @@ -1,6 +1,5 @@ #include "rpc/common/Validators.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -12,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/AMMInfo.cpp b/src/rpc/handlers/AMMInfo.cpp index 3eb8f3002..685c253c3 100644 --- a/src/rpc/handlers/AMMInfo.cpp +++ b/src/rpc/handlers/AMMInfo.cpp @@ -2,7 +2,6 @@ #include "data/DBHelpers.hpp" #include "rpc/AMMHelpers.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/MetaProcessors.hpp" @@ -18,6 +17,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/AccountChannels.cpp b/src/rpc/handlers/AccountChannels.cpp index c977be248..9a2ae4e09 100644 --- a/src/rpc/handlers/AccountChannels.cpp +++ b/src/rpc/handlers/AccountChannels.cpp @@ -1,6 +1,5 @@ #include "rpc/handlers/AccountChannels.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -11,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/AccountCurrencies.cpp b/src/rpc/handlers/AccountCurrencies.cpp index beceda730..a72ebc3e9 100644 --- a/src/rpc/handlers/AccountCurrencies.cpp +++ b/src/rpc/handlers/AccountCurrencies.cpp @@ -1,6 +1,5 @@ #include "rpc/handlers/AccountCurrencies.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -10,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/AccountInfo.cpp b/src/rpc/handlers/AccountInfo.cpp index 83e3d67ae..870e22393 100644 --- a/src/rpc/handlers/AccountInfo.cpp +++ b/src/rpc/handlers/AccountInfo.cpp @@ -1,7 +1,6 @@ #include "rpc/handlers/AccountInfo.hpp" #include "data/AmendmentCenter.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/JsonBool.hpp" @@ -14,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/AccountLines.cpp b/src/rpc/handlers/AccountLines.cpp index 8d0bacee6..982d2deef 100644 --- a/src/rpc/handlers/AccountLines.cpp +++ b/src/rpc/handlers/AccountLines.cpp @@ -1,6 +1,5 @@ #include "rpc/handlers/AccountLines.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -11,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/AccountMPTokenIssuances.cpp b/src/rpc/handlers/AccountMPTokenIssuances.cpp index bd9309e30..22f0c261f 100644 --- a/src/rpc/handlers/AccountMPTokenIssuances.cpp +++ b/src/rpc/handlers/AccountMPTokenIssuances.cpp @@ -1,6 +1,5 @@ #include "rpc/handlers/AccountMPTokenIssuances.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -11,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/AccountMPTokens.cpp b/src/rpc/handlers/AccountMPTokens.cpp index f5381cee2..bede8e56c 100644 --- a/src/rpc/handlers/AccountMPTokens.cpp +++ b/src/rpc/handlers/AccountMPTokens.cpp @@ -1,6 +1,5 @@ #include "rpc/handlers/AccountMPTokens.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -12,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/AccountNFTs.cpp b/src/rpc/handlers/AccountNFTs.cpp index 96b7f9582..2e65fc6cb 100644 --- a/src/rpc/handlers/AccountNFTs.cpp +++ b/src/rpc/handlers/AccountNFTs.cpp @@ -1,6 +1,5 @@ #include "rpc/handlers/AccountNFTs.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -10,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/AccountObjects.cpp b/src/rpc/handlers/AccountObjects.cpp index 183ebd4e1..cdde3372b 100644 --- a/src/rpc/handlers/AccountObjects.cpp +++ b/src/rpc/handlers/AccountObjects.cpp @@ -1,6 +1,5 @@ #include "rpc/handlers/AccountObjects.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -12,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/AccountOffers.cpp b/src/rpc/handlers/AccountOffers.cpp index 09abb815d..c733ead9f 100644 --- a/src/rpc/handlers/AccountOffers.cpp +++ b/src/rpc/handlers/AccountOffers.cpp @@ -1,6 +1,5 @@ #include "rpc/handlers/AccountOffers.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -11,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/AccountTx.cpp b/src/rpc/handlers/AccountTx.cpp index 70464c34f..afacae392 100644 --- a/src/rpc/handlers/AccountTx.cpp +++ b/src/rpc/handlers/AccountTx.cpp @@ -1,7 +1,6 @@ #include "rpc/handlers/AccountTx.hpp" #include "data/Types.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/JsonBool.hpp" @@ -19,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/DepositAuthorized.cpp b/src/rpc/handlers/DepositAuthorized.cpp index e07fb503d..5ba93019d 100644 --- a/src/rpc/handlers/DepositAuthorized.cpp +++ b/src/rpc/handlers/DepositAuthorized.cpp @@ -1,7 +1,6 @@ #include "rpc/handlers/DepositAuthorized.hpp" #include "rpc/CredentialHelpers.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -13,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/Feature.cpp b/src/rpc/handlers/Feature.cpp index f9821e5e9..a0b69c490 100644 --- a/src/rpc/handlers/Feature.cpp +++ b/src/rpc/handlers/Feature.cpp @@ -1,7 +1,6 @@ #include "rpc/handlers/Feature.hpp" #include "data/Types.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/MetaProcessors.hpp" @@ -14,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/GatewayBalances.cpp b/src/rpc/handlers/GatewayBalances.cpp index e9585d2be..294bdd74c 100644 --- a/src/rpc/handlers/GatewayBalances.cpp +++ b/src/rpc/handlers/GatewayBalances.cpp @@ -1,6 +1,5 @@ #include "rpc/handlers/GatewayBalances.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -12,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/GetAggregatePrice.cpp b/src/rpc/handlers/GetAggregatePrice.cpp index 0b8cc519a..4d464a1f8 100644 --- a/src/rpc/handlers/GetAggregatePrice.cpp +++ b/src/rpc/handlers/GetAggregatePrice.cpp @@ -1,6 +1,5 @@ #include "rpc/handlers/GetAggregatePrice.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" diff --git a/src/rpc/handlers/LedgerData.cpp b/src/rpc/handlers/LedgerData.cpp index 9a05caa40..74724980c 100644 --- a/src/rpc/handlers/LedgerData.cpp +++ b/src/rpc/handlers/LedgerData.cpp @@ -1,7 +1,6 @@ #include "rpc/handlers/LedgerData.hpp" #include "data/Types.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -14,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/LedgerEntry.cpp b/src/rpc/handlers/LedgerEntry.cpp index bef9c8666..e577d5c0f 100644 --- a/src/rpc/handlers/LedgerEntry.cpp +++ b/src/rpc/handlers/LedgerEntry.cpp @@ -1,7 +1,6 @@ #include "rpc/handlers/LedgerEntry.hpp" #include "rpc/CredentialHelpers.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -13,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/LedgerIndex.cpp b/src/rpc/handlers/LedgerIndex.cpp index 0315b242b..350f96b09 100644 --- a/src/rpc/handlers/LedgerIndex.cpp +++ b/src/rpc/handlers/LedgerIndex.cpp @@ -1,6 +1,5 @@ #include "rpc/handlers/LedgerIndex.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/common/Types.hpp" #include "util/Assert.hpp" @@ -9,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/MPTHolders.cpp b/src/rpc/handlers/MPTHolders.cpp index 247f7a815..e84181ccd 100644 --- a/src/rpc/handlers/MPTHolders.cpp +++ b/src/rpc/handlers/MPTHolders.cpp @@ -1,6 +1,5 @@ #include "rpc/handlers/MPTHolders.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -11,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/MPTokenIssuanceHistory.cpp b/src/rpc/handlers/MPTokenIssuanceHistory.cpp index 813528ed3..b03d6b78c 100644 --- a/src/rpc/handlers/MPTokenIssuanceHistory.cpp +++ b/src/rpc/handlers/MPTokenIssuanceHistory.cpp @@ -1,7 +1,6 @@ #include "rpc/handlers/MPTokenIssuanceHistory.hpp" #include "data/Types.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -15,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/NFTHistory.cpp b/src/rpc/handlers/NFTHistory.cpp index 51a1f1791..f2229f721 100644 --- a/src/rpc/handlers/NFTHistory.cpp +++ b/src/rpc/handlers/NFTHistory.cpp @@ -1,7 +1,6 @@ #include "rpc/handlers/NFTHistory.hpp" #include "data/Types.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -15,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/NFTInfo.cpp b/src/rpc/handlers/NFTInfo.cpp index acaad62b9..6506d78ce 100644 --- a/src/rpc/handlers/NFTInfo.cpp +++ b/src/rpc/handlers/NFTInfo.cpp @@ -1,6 +1,5 @@ #include "rpc/handlers/NFTInfo.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -11,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/NFTOffersCommon.cpp b/src/rpc/handlers/NFTOffersCommon.cpp index ce4efe203..b3797b14e 100644 --- a/src/rpc/handlers/NFTOffersCommon.cpp +++ b/src/rpc/handlers/NFTOffersCommon.cpp @@ -1,6 +1,5 @@ #include "rpc/handlers/NFTOffersCommon.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -12,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/NFTsByIssuer.cpp b/src/rpc/handlers/NFTsByIssuer.cpp index 471b50d9a..ca5a2eed8 100644 --- a/src/rpc/handlers/NFTsByIssuer.cpp +++ b/src/rpc/handlers/NFTsByIssuer.cpp @@ -1,6 +1,5 @@ #include "rpc/handlers/NFTsByIssuer.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -11,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/NoRippleCheck.cpp b/src/rpc/handlers/NoRippleCheck.cpp index 10d3dd091..2a5ff1601 100644 --- a/src/rpc/handlers/NoRippleCheck.cpp +++ b/src/rpc/handlers/NoRippleCheck.cpp @@ -1,6 +1,5 @@ #include "rpc/handlers/NoRippleCheck.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/JsonBool.hpp" @@ -14,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/Subscribe.cpp b/src/rpc/handlers/Subscribe.cpp index 078215457..d0f2a4074 100644 --- a/src/rpc/handlers/Subscribe.cpp +++ b/src/rpc/handlers/Subscribe.cpp @@ -5,7 +5,6 @@ #include "data/Types.hpp" #include "feed/SubscriptionManagerInterface.hpp" #include "feed/Types.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Checkers.hpp" @@ -21,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/TransactionEntry.cpp b/src/rpc/handlers/TransactionEntry.cpp index 9d2146756..083023bfb 100644 --- a/src/rpc/handlers/TransactionEntry.cpp +++ b/src/rpc/handlers/TransactionEntry.cpp @@ -1,6 +1,5 @@ #include "rpc/handlers/TransactionEntry.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -10,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/src/rpc/handlers/Unsubscribe.cpp b/src/rpc/handlers/Unsubscribe.cpp index d0923cd4e..f7c521adf 100644 --- a/src/rpc/handlers/Unsubscribe.cpp +++ b/src/rpc/handlers/Unsubscribe.cpp @@ -2,7 +2,6 @@ #include "feed/SubscriptionManagerInterface.hpp" #include "feed/Types.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Checkers.hpp" @@ -14,6 +13,7 @@ #include #include #include +#include #include #include diff --git a/src/rpc/handlers/VaultInfo.cpp b/src/rpc/handlers/VaultInfo.cpp index 967f19a03..7fee9f2ae 100644 --- a/src/rpc/handlers/VaultInfo.cpp +++ b/src/rpc/handlers/VaultInfo.cpp @@ -1,7 +1,6 @@ #include "rpc/handlers/VaultInfo.hpp" #include "data/BackendInterface.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" @@ -11,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/src/web/CMakeLists.txt b/src/web/CMakeLists.txt index facc5e258..2a0db40a6 100644 --- a/src/web/CMakeLists.txt +++ b/src/web/CMakeLists.txt @@ -21,4 +21,4 @@ target_sources( SubscriptionContext.cpp ) -target_link_libraries(clio_web PUBLIC clio_util) +target_link_libraries(clio_web PUBLIC clio_util rpcspec::rpcspec) diff --git a/src/web/impl/ErrorHandling.hpp b/src/web/impl/ErrorHandling.hpp index 2f631b448..f14e6131c 100644 --- a/src/web/impl/ErrorHandling.hpp +++ b/src/web/impl/ErrorHandling.hpp @@ -80,10 +80,10 @@ public: case rpc::ClioError::RpcFieldNotFoundTransaction: case rpc::ClioError::RpcMalformedOracleDocumentId: case rpc::ClioError::RpcMalformedAuthorizedCredentials: - case rpc::ClioError::EtlConnectionError: - case rpc::ClioError::EtlRequestError: - case rpc::ClioError::EtlRequestTimeout: - case rpc::ClioError::EtlInvalidResponse: + case rpc::ClioError::RpcForwardingConnectionError: + case rpc::ClioError::RpcForwardingRequestError: + case rpc::ClioError::RpcForwardingTimeout: + case rpc::ClioError::RpcForwardingInvalidResponse: ASSERT( false, "Unknown rpc error code {}", static_cast(*clioCode) ); // this should never happen diff --git a/src/web/ng/impl/ErrorHandling.cpp b/src/web/ng/impl/ErrorHandling.cpp index c86ce259a..a1b5bebe3 100644 --- a/src/web/ng/impl/ErrorHandling.cpp +++ b/src/web/ng/impl/ErrorHandling.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -92,10 +93,10 @@ ErrorHelper::makeError(rpc::Status const& err) const case rpc::ClioError::RpcFieldNotFoundTransaction: case rpc::ClioError::RpcMalformedOracleDocumentId: case rpc::ClioError::RpcMalformedAuthorizedCredentials: - case rpc::ClioError::EtlConnectionError: - case rpc::ClioError::EtlRequestError: - case rpc::ClioError::EtlRequestTimeout: - case rpc::ClioError::EtlInvalidResponse: + case rpc::ClioError::RpcForwardingConnectionError: + case rpc::ClioError::RpcForwardingRequestError: + case rpc::ClioError::RpcForwardingTimeout: + case rpc::ClioError::RpcForwardingInvalidResponse: ASSERT( false, "Unknown rpc error code {}", static_cast(*clioCode) ); // this should never happen diff --git a/tests/common/util/MockSource.hpp b/tests/common/util/MockSource.hpp index fbc4c4bbc..31db732da 100644 --- a/tests/common/util/MockSource.hpp +++ b/tests/common/util/MockSource.hpp @@ -5,7 +5,6 @@ #include "etl/NetworkValidatedLedgersInterface.hpp" #include "etl/Source.hpp" #include "feed/SubscriptionManagerInterface.hpp" -#include "rpc/Errors.hpp" #include "util/config/ObjectView.hpp" #include @@ -16,6 +15,7 @@ #include #include #include +#include #include #include diff --git a/tests/unit/app/WebHandlersTests.cpp b/tests/unit/app/WebHandlersTests.cpp index cf86f38f4..5377ef479 100644 --- a/tests/unit/app/WebHandlersTests.cpp +++ b/tests/unit/app/WebHandlersTests.cpp @@ -1,5 +1,4 @@ #include "app/WebHandlers.hpp" -#include "rpc/Errors.hpp" #include "rpc/WorkQueue.hpp" #include "util/AsioContextTestFixture.hpp" #include "util/MockLedgerCache.hpp" @@ -24,6 +23,7 @@ #include #include #include +#include #include #include diff --git a/tests/unit/etl/ETLStateTests.cpp b/tests/unit/etl/ETLStateTests.cpp index 3db5702f6..09dbf259f 100644 --- a/tests/unit/etl/ETLStateTests.cpp +++ b/tests/unit/etl/ETLStateTests.cpp @@ -1,10 +1,10 @@ #include "etl/ETLState.hpp" -#include "rpc/Errors.hpp" #include "util/MockSource.hpp" #include #include #include +#include #include @@ -18,7 +18,7 @@ struct ETLStateTest : public virtual ::testing::Test { TEST_F(ETLStateTest, Error) { EXPECT_CALL(source, forwardToRippled) - .WillOnce(Return(std::unexpected{rpc::ClioError::EtlInvalidResponse})); + .WillOnce(Return(std::unexpected{rpc::ClioError::RpcForwardingInvalidResponse})); auto const state = etl::ETLState::fetchETLStateFromSource(source); EXPECT_FALSE(state); } diff --git a/tests/unit/etl/ForwardingSourceTests.cpp b/tests/unit/etl/ForwardingSourceTests.cpp index f85d7ba93..e7f9e0822 100644 --- a/tests/unit/etl/ForwardingSourceTests.cpp +++ b/tests/unit/etl/ForwardingSourceTests.cpp @@ -1,5 +1,4 @@ #include "etl/impl/ForwardingSource.hpp" -#include "rpc/Errors.hpp" #include "util/AsioContextTestFixture.hpp" #include "util/Spawn.hpp" #include "util/TestWsServer.hpp" @@ -9,6 +8,7 @@ #include #include #include +#include #include #include @@ -35,7 +35,7 @@ TEST_F(ForwardingSourceTests, ConnectionFailed) runSpawn([&](boost::asio::yield_context yield) { auto result = forwardingSource_.forwardToRippled({}, {}, {}, yield); ASSERT_FALSE(result); - EXPECT_EQ(result.error(), rpc::ClioError::EtlConnectionError); + EXPECT_EQ(result.error(), rpc::ClioError::RpcForwardingConnectionError); }); } @@ -79,7 +79,7 @@ TEST_F(ForwardingSourceOperationsTests, XUserHeader) boost::json::parse(message_).as_object(), {}, xUserValue, yield ); ASSERT_FALSE(result); - EXPECT_EQ(result.error(), rpc::ClioError::EtlRequestError); + EXPECT_EQ(result.error(), rpc::ClioError::RpcForwardingRequestError); }); } @@ -95,7 +95,7 @@ TEST_F(ForwardingSourceOperationsTests, ReadFailed) boost::json::parse(message_).as_object(), {}, {}, yield ); ASSERT_FALSE(result); - EXPECT_EQ(result.error(), rpc::ClioError::EtlRequestError); + EXPECT_EQ(result.error(), rpc::ClioError::RpcForwardingRequestError); }); } @@ -111,7 +111,7 @@ TEST_F(ForwardingSourceOperationsTests, ReadTimeout) boost::json::parse(message_).as_object(), {}, {}, yield ); ASSERT_FALSE(result); - EXPECT_EQ(result.error(), rpc::ClioError::EtlRequestTimeout); + EXPECT_EQ(result.error(), rpc::ClioError::RpcForwardingTimeout); }); } @@ -136,7 +136,7 @@ TEST_F(ForwardingSourceOperationsTests, ParseFailed) boost::json::parse(message_).as_object(), {}, {}, yield ); ASSERT_FALSE(result); - EXPECT_EQ(result.error(), rpc::ClioError::EtlInvalidResponse); + EXPECT_EQ(result.error(), rpc::ClioError::RpcForwardingInvalidResponse); }); } @@ -162,7 +162,7 @@ TEST_F(ForwardingSourceOperationsTests, GotNotAnObject) boost::json::parse(message_).as_object(), {}, {}, yield ); ASSERT_FALSE(result); - EXPECT_EQ(result.error(), rpc::ClioError::EtlInvalidResponse); + EXPECT_EQ(result.error(), rpc::ClioError::RpcForwardingInvalidResponse); }); } diff --git a/tests/unit/etl/LoadBalancerTests.cpp b/tests/unit/etl/LoadBalancerTests.cpp index 243c27616..35da1f713 100644 --- a/tests/unit/etl/LoadBalancerTests.cpp +++ b/tests/unit/etl/LoadBalancerTests.cpp @@ -3,7 +3,6 @@ #include "etl/LoadBalancerInterface.hpp" #include "etl/Models.hpp" #include "etl/Source.hpp" -#include "rpc/Errors.hpp" #include "util/AsioContextTestFixture.hpp" #include "util/MockBackendTestFixture.hpp" #include "util/MockNetworkValidatedLedgers.hpp" @@ -30,6 +29,7 @@ #include #include #include +#include #include #include @@ -203,9 +203,9 @@ TEST_F(LoadBalancerConstructorTests, fetchETLState_AllSourcesFail) { EXPECT_CALL(sourceFactory_, makeSource).Times(2); EXPECT_CALL(sourceFactory_.sourceAt(0), forwardToRippled) - .WillOnce(Return(std::unexpected{rpc::ClioError::EtlConnectionError})); + .WillOnce(Return(std::unexpected{rpc::ClioError::RpcForwardingConnectionError})); EXPECT_CALL(sourceFactory_.sourceAt(1), forwardToRippled) - .WillOnce(Return(std::unexpected{rpc::ClioError::EtlConnectionError})); + .WillOnce(Return(std::unexpected{rpc::ClioError::RpcForwardingConnectionError})); EXPECT_THROW({ makeLoadBalancer(); }, std::logic_error); } @@ -225,7 +225,7 @@ TEST_F(LoadBalancerConstructorTests, fetchETLState_Source1Fails0OK) EXPECT_CALL(sourceFactory_.sourceAt(0), forwardToRippled) .WillOnce(Return(boost::json::object{})); EXPECT_CALL(sourceFactory_.sourceAt(1), forwardToRippled) - .WillOnce(Return(std::unexpected{rpc::ClioError::EtlConnectionError})); + .WillOnce(Return(std::unexpected{rpc::ClioError::RpcForwardingConnectionError})); EXPECT_CALL(sourceFactory_.sourceAt(0), run); EXPECT_CALL(sourceFactory_.sourceAt(1), run); makeLoadBalancer(); @@ -235,7 +235,7 @@ TEST_F(LoadBalancerConstructorTests, fetchETLState_Source0Fails1OK) { EXPECT_CALL(sourceFactory_, makeSource).Times(2); EXPECT_CALL(sourceFactory_.sourceAt(0), forwardToRippled) - .WillOnce(Return(std::unexpected{rpc::ClioError::EtlConnectionError})); + .WillOnce(Return(std::unexpected{rpc::ClioError::RpcForwardingConnectionError})); EXPECT_CALL(sourceFactory_.sourceAt(1), forwardToRippled) .WillOnce(Return(boost::json::object{})); EXPECT_CALL(sourceFactory_.sourceAt(0), run); @@ -265,7 +265,7 @@ TEST_F(LoadBalancerConstructorTests, fetchETLState_AllSourcesFailButAllowNoEtlIs .WillOnce(Return(boost::json::object{})); EXPECT_CALL(sourceFactory_.sourceAt(0), run); EXPECT_CALL(sourceFactory_.sourceAt(1), forwardToRippled) - .WillOnce(Return(std::unexpected{rpc::ClioError::EtlConnectionError})); + .WillOnce(Return(std::unexpected{rpc::ClioError::RpcForwardingConnectionError})); EXPECT_CALL(sourceFactory_.sourceAt(1), run); configJson_.as_object()["allow_no_etl"] = true; @@ -716,7 +716,7 @@ TEST_F(LoadBalancerForwardToRippledTests, source0Fails) sourceFactory_.sourceAt(0), forwardToRippled(request_, clientIP_, LoadBalancer::kUserForwardingXUserValue, testing::_) ) - .WillOnce(Return(std::unexpected{rpc::ClioError::EtlConnectionError})); + .WillOnce(Return(std::unexpected{rpc::ClioError::RpcForwardingConnectionError})); EXPECT_CALL( sourceFactory_.sourceAt(1), forwardToRippled(request_, clientIP_, LoadBalancer::kUserForwardingXUserValue, testing::_) @@ -819,7 +819,7 @@ TEST_F(LoadBalancerForwardToRippledPrometheusTests, source0Fails) sourceFactory_.sourceAt(0), forwardToRippled(request_, clientIP_, LoadBalancer::kUserForwardingXUserValue, testing::_) ) - .WillOnce(Return(std::unexpected{rpc::ClioError::EtlConnectionError})); + .WillOnce(Return(std::unexpected{rpc::ClioError::RpcForwardingConnectionError})); EXPECT_CALL( sourceFactory_.sourceAt(1), forwardToRippled(request_, clientIP_, LoadBalancer::kUserForwardingXUserValue, testing::_) @@ -876,33 +876,33 @@ INSTANTIATE_TEST_SUITE_P( testing::Values( LoadBalancerForwardToRippledErrorTestBundle{ "ConnectionError_RequestError", - rpc::ClioError::EtlConnectionError, - rpc::ClioError::EtlRequestError, - rpc::ClioError::EtlRequestError + rpc::ClioError::RpcForwardingConnectionError, + rpc::ClioError::RpcForwardingRequestError, + rpc::ClioError::RpcForwardingRequestError }, LoadBalancerForwardToRippledErrorTestBundle{ "RequestError_RequestTimeout", - rpc::ClioError::EtlRequestError, - rpc::ClioError::EtlRequestTimeout, - rpc::ClioError::EtlRequestTimeout + rpc::ClioError::RpcForwardingRequestError, + rpc::ClioError::RpcForwardingTimeout, + rpc::ClioError::RpcForwardingTimeout }, LoadBalancerForwardToRippledErrorTestBundle{ "RequestTimeout_InvalidResponse", - rpc::ClioError::EtlRequestTimeout, - rpc::ClioError::EtlInvalidResponse, - rpc::ClioError::EtlInvalidResponse + rpc::ClioError::RpcForwardingTimeout, + rpc::ClioError::RpcForwardingInvalidResponse, + rpc::ClioError::RpcForwardingInvalidResponse }, LoadBalancerForwardToRippledErrorTestBundle{ "BothRequestTimeout", - rpc::ClioError::EtlRequestTimeout, - rpc::ClioError::EtlRequestTimeout, - rpc::ClioError::EtlRequestTimeout + rpc::ClioError::RpcForwardingTimeout, + rpc::ClioError::RpcForwardingTimeout, + rpc::ClioError::RpcForwardingTimeout }, LoadBalancerForwardToRippledErrorTestBundle{ "InvalidResponse_RequestError", - rpc::ClioError::EtlInvalidResponse, - rpc::ClioError::EtlRequestError, - rpc::ClioError::EtlInvalidResponse + rpc::ClioError::RpcForwardingInvalidResponse, + rpc::ClioError::RpcForwardingRequestError, + rpc::ClioError::RpcForwardingInvalidResponse } ), tests::util::kNameGenerator diff --git a/tests/unit/etl/SourceImplTests.cpp b/tests/unit/etl/SourceImplTests.cpp index 999f01cbd..31acac3f7 100644 --- a/tests/unit/etl/SourceImplTests.cpp +++ b/tests/unit/etl/SourceImplTests.cpp @@ -2,7 +2,6 @@ #include "etl/LoadBalancerInterface.hpp" #include "etl/Models.hpp" #include "etl/impl/SourceImpl.hpp" -#include "rpc/Errors.hpp" #include "util/Spawn.hpp" #include @@ -13,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/tests/unit/rpc/BaseTests.cpp b/tests/unit/rpc/BaseTests.cpp index bbff83ed6..70f49b011 100644 --- a/tests/unit/rpc/BaseTests.cpp +++ b/tests/unit/rpc/BaseTests.cpp @@ -1,4 +1,3 @@ -#include "rpc/Errors.hpp" #include "rpc/common/MetaProcessors.hpp" #include "rpc/common/Modifiers.hpp" #include "rpc/common/Specs.hpp" @@ -13,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/tests/unit/rpc/ErrorTests.cpp b/tests/unit/rpc/ErrorTests.cpp index 2f7866254..5952069aa 100644 --- a/tests/unit/rpc/ErrorTests.cpp +++ b/tests/unit/rpc/ErrorTests.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -150,7 +151,7 @@ INSTANTIATE_TEST_SUITE_P( "Clio", WarningCode::WarnRpcClio, "This is a clio server. clio only serves validated data. If you want to talk to " - "rippled, include " + "xrpld, include " "'ledger_index':'current' in your request" }, WarningCodeTestBundle{ @@ -234,7 +235,7 @@ INSTANTIATE_TEST_SUITE_P( }, StatusStreamTestBundle{ .testName = "StatusWithCodeAndExtraInfo", - .status = Status{ClioError::EtlConnectionError, boost::json::object{}}, + .status = Status{ClioError::RpcForwardingConnectionError, boost::json::object{}}, .expectedOutput = "Code: 7000, Message: Couldn't connect to rippled., Extra Info: {}" }, StatusStreamTestBundle{ @@ -256,7 +257,7 @@ INSTANTIATE_TEST_SUITE_P( .testName = "StatusWithCodeErrorMessage", .status = Status{ - ClioError::EtlInvalidResponse, + ClioError::RpcForwardingInvalidResponse, "invalidResponse", "Rippled returned an invalid response." }, diff --git a/tests/unit/rpc/ForwardingProxyTests.cpp b/tests/unit/rpc/ForwardingProxyTests.cpp index 396bfb5eb..a8cac87ea 100644 --- a/tests/unit/rpc/ForwardingProxyTests.cpp +++ b/tests/unit/rpc/ForwardingProxyTests.cpp @@ -1,5 +1,4 @@ #include "data/Types.hpp" -#include "rpc/Errors.hpp" #include "rpc/common/impl/ForwardingProxy.hpp" #include "util/HandlerBaseTestFixture.hpp" #include "util/MockCounters.hpp" @@ -16,6 +15,7 @@ #include #include #include +#include #include #include @@ -338,7 +338,7 @@ TEST_F(RPCForwardingProxyTest, ForwardingFailYieldsErrorStatus) *rawBalancerPtr, forwardToRippled(forwarded.as_object(), std::make_optional(kClientIp), true, _) ) - .WillOnce(Return(std::unexpected{rpc::ClioError::EtlInvalidResponse})); + .WillOnce(Return(std::unexpected{rpc::ClioError::RpcForwardingInvalidResponse})); EXPECT_CALL(*rawHandlerProviderPtr, contains(method)).WillOnce(Return(true)); @@ -360,6 +360,6 @@ TEST_F(RPCForwardingProxyTest, ForwardingFailYieldsErrorStatus) auto const res = proxy_.forward(ctx); EXPECT_FALSE(res.response.has_value()); - EXPECT_EQ(res.response.error(), rpc::ClioError::EtlInvalidResponse); + EXPECT_EQ(res.response.error(), rpc::ClioError::RpcForwardingInvalidResponse); }); } diff --git a/tests/unit/rpc/RPCEngineTests.cpp b/tests/unit/rpc/RPCEngineTests.cpp index 48820e48b..840e05c5c 100644 --- a/tests/unit/rpc/RPCEngineTests.cpp +++ b/tests/unit/rpc/RPCEngineTests.cpp @@ -1,6 +1,5 @@ #include "data/BackendInterface.hpp" #include "data/Types.hpp" -#include "rpc/Errors.hpp" #include "rpc/FakesAndMocks.hpp" #include "rpc/RPCEngine.hpp" #include "rpc/WorkQueue.hpp" @@ -29,6 +28,7 @@ #include #include #include +#include #include #include diff --git a/tests/unit/rpc/RPCHelpersTests.cpp b/tests/unit/rpc/RPCHelpersTests.cpp index 651682eaf..55fce5e97 100644 --- a/tests/unit/rpc/RPCHelpersTests.cpp +++ b/tests/unit/rpc/RPCHelpersTests.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/unit/rpc/common/CheckersTests.cpp b/tests/unit/rpc/common/CheckersTests.cpp index 2c34322cb..a9c99d899 100644 --- a/tests/unit/rpc/common/CheckersTests.cpp +++ b/tests/unit/rpc/common/CheckersTests.cpp @@ -1,8 +1,8 @@ -#include "rpc/Errors.hpp" #include "rpc/common/Checkers.hpp" #include #include +#include #include diff --git a/tests/unit/rpc/common/SpecsTests.cpp b/tests/unit/rpc/common/SpecsTests.cpp index 8e48db857..620a22b7c 100644 --- a/tests/unit/rpc/common/SpecsTests.cpp +++ b/tests/unit/rpc/common/SpecsTests.cpp @@ -1,4 +1,3 @@ -#include "rpc/Errors.hpp" #include "rpc/common/Checkers.hpp" #include "rpc/common/Specs.hpp" #include "rpc/common/Types.hpp" @@ -7,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/tests/unit/rpc/common/TypesTests.cpp b/tests/unit/rpc/common/TypesTests.cpp index 3ee5eb037..eec172d5a 100644 --- a/tests/unit/rpc/common/TypesTests.cpp +++ b/tests/unit/rpc/common/TypesTests.cpp @@ -1,4 +1,3 @@ -#include "rpc/Errors.hpp" #include "rpc/common/Types.hpp" #include diff --git a/tests/unit/rpc/handlers/AccountCurrenciesTests.cpp b/tests/unit/rpc/handlers/AccountCurrenciesTests.cpp index 8220331d5..909a75279 100644 --- a/tests/unit/rpc/handlers/AccountCurrenciesTests.cpp +++ b/tests/unit/rpc/handlers/AccountCurrenciesTests.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/unit/rpc/handlers/AccountInfoTests.cpp b/tests/unit/rpc/handlers/AccountInfoTests.cpp index 85a1b3c34..e28bceb96 100644 --- a/tests/unit/rpc/handlers/AccountInfoTests.cpp +++ b/tests/unit/rpc/handlers/AccountInfoTests.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/unit/rpc/handlers/AccountLinesTests.cpp b/tests/unit/rpc/handlers/AccountLinesTests.cpp index d473349cf..e9f42ba93 100644 --- a/tests/unit/rpc/handlers/AccountLinesTests.cpp +++ b/tests/unit/rpc/handlers/AccountLinesTests.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/unit/rpc/handlers/AccountOffersTests.cpp b/tests/unit/rpc/handlers/AccountOffersTests.cpp index 447968bd8..e9d70b111 100644 --- a/tests/unit/rpc/handlers/AccountOffersTests.cpp +++ b/tests/unit/rpc/handlers/AccountOffersTests.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/unit/rpc/handlers/CredentialHelpersTests.cpp b/tests/unit/rpc/handlers/CredentialHelpersTests.cpp index 07cf381b0..b11935bb5 100644 --- a/tests/unit/rpc/handlers/CredentialHelpersTests.cpp +++ b/tests/unit/rpc/handlers/CredentialHelpersTests.cpp @@ -1,5 +1,4 @@ #include "rpc/CredentialHelpers.hpp" -#include "rpc/Errors.hpp" #include "rpc/JS.hpp" #include "util/AsioContextTestFixture.hpp" #include "util/MockBackendTestFixture.hpp" @@ -12,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/unit/rpc/handlers/LedgerDataTests.cpp b/tests/unit/rpc/handlers/LedgerDataTests.cpp index 5e3255ee7..3bf7ed676 100644 --- a/tests/unit/rpc/handlers/LedgerDataTests.cpp +++ b/tests/unit/rpc/handlers/LedgerDataTests.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/unit/rpc/handlers/LedgerEntryTests.cpp b/tests/unit/rpc/handlers/LedgerEntryTests.cpp index 8f968fbce..e9276e6c6 100644 --- a/tests/unit/rpc/handlers/LedgerEntryTests.cpp +++ b/tests/unit/rpc/handlers/LedgerEntryTests.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/unit/rpc/handlers/LedgerTests.cpp b/tests/unit/rpc/handlers/LedgerTests.cpp index 1b04f60af..6ce57bb94 100644 --- a/tests/unit/rpc/handlers/LedgerTests.cpp +++ b/tests/unit/rpc/handlers/LedgerTests.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/unit/rpc/handlers/ServerInfoTests.cpp b/tests/unit/rpc/handlers/ServerInfoTests.cpp index c1e7cbdfc..84b7427e8 100644 --- a/tests/unit/rpc/handlers/ServerInfoTests.cpp +++ b/tests/unit/rpc/handlers/ServerInfoTests.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -177,7 +178,7 @@ TEST_F(RPCServerInfoHandlerTest, DefaultOutputIsPresent) EXPECT_CALL( *rawBalancerPtr, forwardToRippled(testing::_, testing::Eq(kClientIp), false, testing::_) ) - .WillOnce(Return(std::unexpected{rpc::ClioError::EtlInvalidResponse})); + .WillOnce(Return(std::unexpected{rpc::ClioError::RpcForwardingInvalidResponse})); EXPECT_CALL(*rawCountersPtr, uptime).WillOnce(Return(std::chrono::seconds{1234})); @@ -220,7 +221,7 @@ TEST_F(RPCServerInfoHandlerTest, AmendmentBlockedIsPresentIfSet) EXPECT_CALL( *rawBalancerPtr, forwardToRippled(testing::_, testing::Eq(kClientIp), false, testing::_) ) - .WillOnce(Return(std::unexpected{rpc::ClioError::EtlInvalidResponse})); + .WillOnce(Return(std::unexpected{rpc::ClioError::RpcForwardingInvalidResponse})); EXPECT_CALL(*rawCountersPtr, uptime).WillOnce(Return(std::chrono::seconds{1234})); @@ -261,7 +262,7 @@ TEST_F(RPCServerInfoHandlerTest, CorruptionDetectedIsPresentIfSet) EXPECT_CALL( *rawBalancerPtr, forwardToRippled(testing::_, testing::Eq(kClientIp), false, testing::_) ) - .WillOnce(Return(std::unexpected{rpc::ClioError::EtlInvalidResponse})); + .WillOnce(Return(std::unexpected{rpc::ClioError::RpcForwardingInvalidResponse})); EXPECT_CALL(*rawCountersPtr, uptime).WillOnce(Return(std::chrono::seconds{1234})); @@ -302,7 +303,7 @@ TEST_F(RPCServerInfoHandlerTest, CacheReportsEnabledFlagCorrectly) *rawBalancerPtr, forwardToRippled(testing::_, testing::Eq(kClientIp), false, testing::_) ) .Times(2) - .WillRepeatedly(Return(std::unexpected{rpc::ClioError::EtlInvalidResponse})); + .WillRepeatedly(Return(std::unexpected{rpc::ClioError::RpcForwardingInvalidResponse})); EXPECT_CALL(*rawCountersPtr, uptime) .Times(2) diff --git a/tests/unit/rpc/handlers/SubscribeTests.cpp b/tests/unit/rpc/handlers/SubscribeTests.cpp index 28e77e729..83d8af706 100644 --- a/tests/unit/rpc/handlers/SubscribeTests.cpp +++ b/tests/unit/rpc/handlers/SubscribeTests.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/unit/rpc/handlers/TestHandlerTests.cpp b/tests/unit/rpc/handlers/TestHandlerTests.cpp index c30c39f15..84a07769f 100644 --- a/tests/unit/rpc/handlers/TestHandlerTests.cpp +++ b/tests/unit/rpc/handlers/TestHandlerTests.cpp @@ -6,6 +6,7 @@ #include #include +#include using namespace std; using namespace rpc; diff --git a/tests/unit/rpc/handlers/TxTests.cpp b/tests/unit/rpc/handlers/TxTests.cpp index b8acacc69..e7e4f63fc 100644 --- a/tests/unit/rpc/handlers/TxTests.cpp +++ b/tests/unit/rpc/handlers/TxTests.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/tests/unit/rpc/handlers/UnsubscribeTests.cpp b/tests/unit/rpc/handlers/UnsubscribeTests.cpp index c515bf775..04c23300e 100644 --- a/tests/unit/rpc/handlers/UnsubscribeTests.cpp +++ b/tests/unit/rpc/handlers/UnsubscribeTests.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include diff --git a/tests/unit/rpc/handlers/VaultInfoTests.cpp b/tests/unit/rpc/handlers/VaultInfoTests.cpp index f1fc0afb0..73e9dc580 100644 --- a/tests/unit/rpc/handlers/VaultInfoTests.cpp +++ b/tests/unit/rpc/handlers/VaultInfoTests.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/unit/web/LoadWarningTests.cpp b/tests/unit/web/LoadWarningTests.cpp index c4adaf34a..d174981bb 100644 --- a/tests/unit/web/LoadWarningTests.cpp +++ b/tests/unit/web/LoadWarningTests.cpp @@ -1,7 +1,7 @@ -#include "rpc/Errors.hpp" #include "web/LoadWarning.hpp" #include +#include #include #include diff --git a/tests/unit/web/RPCServerHandlerTests.cpp b/tests/unit/web/RPCServerHandlerTests.cpp index 4b5fb0fdd..fb9879654 100644 --- a/tests/unit/web/RPCServerHandlerTests.cpp +++ b/tests/unit/web/RPCServerHandlerTests.cpp @@ -1,4 +1,3 @@ -#include "rpc/Errors.hpp" #include "rpc/common/APIVersion.hpp" #include "rpc/common/Types.hpp" #include "util/AsioContextTestFixture.hpp" @@ -21,6 +20,7 @@ #include #include #include +#include #include #include @@ -122,7 +122,7 @@ TEST_F(WebRPCServerHandlerTest, HTTPDefaultPath) "warnings": [ { "id": 2001, - "message": "This is a clio server. clio only serves validated data. If you want to talk to rippled, include 'ledger_index':'current' in your request" + "message": "This is a clio server. clio only serves validated data. If you want to talk to xrpld, include 'ledger_index':'current' in your request" } ] })JSON"; @@ -190,7 +190,7 @@ TEST_F(WebRPCServerHandlerTest, WsNormalPath) "warnings": [ { "id": 2001, - "message": "This is a clio server. clio only serves validated data. If you want to talk to rippled, include 'ledger_index':'current' in your request" + "message": "This is a clio server. clio only serves validated data. If you want to talk to xrpld, include 'ledger_index':'current' in your request" } ] })JSON"; @@ -265,7 +265,7 @@ TEST_F(WebRPCServerHandlerTest, HTTPForwardedPath) "warnings": [ { "id": 2001, - "message": "This is a clio server. clio only serves validated data. If you want to talk to rippled, include 'ledger_index':'current' in your request" + "message": "This is a clio server. clio only serves validated data. If you want to talk to xrpld, include 'ledger_index':'current' in your request" } ] })JSON"; @@ -314,7 +314,7 @@ TEST_F(WebRPCServerHandlerTest, HTTPForwardedErrorPath) "warnings": [ { "id": 2001, - "message": "This is a clio server. clio only serves validated data. If you want to talk to rippled, include 'ledger_index':'current' in your request" + "message": "This is a clio server. clio only serves validated data. If you want to talk to xrpld, include 'ledger_index':'current' in your request" } ] })JSON"; @@ -361,7 +361,7 @@ TEST_F(WebRPCServerHandlerTest, WsForwardedPath) "warnings": [ { "id": 2001, - "message": "This is a clio server. clio only serves validated data. If you want to talk to rippled, include 'ledger_index':'current' in your request" + "message": "This is a clio server. clio only serves validated data. If you want to talk to xrpld, include 'ledger_index':'current' in your request" } ] })JSON"; @@ -412,7 +412,7 @@ TEST_F(WebRPCServerHandlerTest, WsForwardedErrorPath) "warnings": [ { "id": 2001, - "message": "This is a clio server. clio only serves validated data. If you want to talk to rippled, include 'ledger_index':'current' in your request" + "message": "This is a clio server. clio only serves validated data. If you want to talk to xrpld, include 'ledger_index':'current' in your request" } ] })JSON"; @@ -453,7 +453,7 @@ TEST_F(WebRPCServerHandlerTest, HTTPErrorPath) "warnings": [ { "id": 2001, - "message": "This is a clio server. clio only serves validated data. If you want to talk to rippled, include 'ledger_index':'current' in your request" + "message": "This is a clio server. clio only serves validated data. If you want to talk to xrpld, include 'ledger_index':'current' in your request" } ] })JSON"; @@ -510,7 +510,7 @@ TEST_F(WebRPCServerHandlerTest, WsErrorPath) "warnings": [ { "id": 2001, - "message": "This is a clio server. clio only serves validated data. If you want to talk to rippled, include 'ledger_index':'current' in your request" + "message": "This is a clio server. clio only serves validated data. If you want to talk to xrpld, include 'ledger_index':'current' in your request" } ] })JSON"; @@ -860,7 +860,7 @@ TEST_F(WebRPCServerHandlerTest, HTTPOutDated) "warnings": [ { "id": 2001, - "message": "This is a clio server. clio only serves validated data. If you want to talk to rippled, include 'ledger_index':'current' in your request" + "message": "This is a clio server. clio only serves validated data. If you want to talk to xrpld, include 'ledger_index':'current' in your request" }, { "id": 2002, @@ -903,7 +903,7 @@ TEST_F(WebRPCServerHandlerTest, WsOutdated) "warnings": [ { "id": 2001, - "message": "This is a clio server. clio only serves validated data. If you want to talk to rippled, include 'ledger_index':'current' in your request" + "message": "This is a clio server. clio only serves validated data. If you want to talk to xrpld, include 'ledger_index':'current' in your request" }, { "id": 2002, diff --git a/tests/unit/web/impl/ErrorHandlingTests.cpp b/tests/unit/web/impl/ErrorHandlingTests.cpp index 6b36c4cee..a89d6f12d 100644 --- a/tests/unit/web/impl/ErrorHandlingTests.cpp +++ b/tests/unit/web/impl/ErrorHandlingTests.cpp @@ -1,4 +1,3 @@ -#include "rpc/Errors.hpp" #include "util/NameGenerator.hpp" #include "util/Taggable.hpp" #include "util/config/ConfigDefinition.hpp" @@ -12,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/tests/unit/web/ng/RPCServerHandlerTests.cpp b/tests/unit/web/ng/RPCServerHandlerTests.cpp index 2dab021d4..cda529f6e 100644 --- a/tests/unit/web/ng/RPCServerHandlerTests.cpp +++ b/tests/unit/web/ng/RPCServerHandlerTests.cpp @@ -1,4 +1,3 @@ -#include "rpc/Errors.hpp" #include "rpc/common/Types.hpp" #include "util/AsioContextTestFixture.hpp" #include "util/MockBackendTestFixture.hpp" @@ -25,6 +24,7 @@ #include #include #include +#include #include #include diff --git a/tests/unit/web/ng/impl/ErrorHandlingTests.cpp b/tests/unit/web/ng/impl/ErrorHandlingTests.cpp index f40721c35..2e16147e1 100644 --- a/tests/unit/web/ng/impl/ErrorHandlingTests.cpp +++ b/tests/unit/web/ng/impl/ErrorHandlingTests.cpp @@ -1,4 +1,3 @@ -#include "rpc/Errors.hpp" #include "util/NameGenerator.hpp" #include "web/ng/Request.hpp" #include "web/ng/impl/ErrorHandling.hpp" @@ -11,6 +10,7 @@ #include #include #include +#include #include #include