23#include <boost/json/object.hpp>
24#include <xrpl/protocol/ErrorCodes.h>
38 RpcMalformedCurrency = 5000,
39 RpcMalformedRequest = 5001,
40 RpcMalformedOwner = 5002,
41 RpcMalformedAddress = 5003,
42 RpcUnknownOption = 5005,
43 RpcFieldNotFoundTransaction = 5006,
44 RpcMalformedOracleDocumentId = 5007,
45 RpcMalformedAuthorizedCredentials = 5008,
46 RpcEntryNotFound = 5009,
49 RpcInvalidApiVersion = 6000,
50 RpcCommandIsMissing = 6001,
51 RpcCommandNotString = 6002,
52 RpcCommandIsEmpty = 6003,
53 RpcParamsUnparsable = 6004,
58 EtlConnectionError = 7000,
59 EtlRequestError = 7001,
60 EtlRequestTimeout = 7002,
61 EtlInvalidResponse = 7003,
67 std::string_view
const error;
68 std::string_view
const message;
87 std::optional<boost::json::object> extraInfo;
104 Status(
CombinedError code, boost::json::object&& extraInfo) : code(code), extraInfo(std::move(extraInfo)) {};
114 explicit Status(std::string message) : code(ripple::rpcUNKNOWN), message(std::move(message))
136 : code(code), error(std::move(error)), message(std::move(message))
141 operator==(
Status const& other)
const =
default;
148 operator bool()
const
150 if (
auto err = std::get_if<RippledError>(&code))
151 return *err != RippledError::rpcSUCCESS;
165 if (
auto err = std::get_if<RippledError>(&code))
166 return *err == other;
180 if (
auto err = std::get_if<ClioError>(&code))
181 return *err == other;
191 WarnRpcOutdated = 2002,
192 WarnRpcRateLimit = 2003,
193 WarnRpcDeprecated = 2004
211 std::string_view
const message =
"unknown warning";
242 std::string account_;
262 return account_.c_str();
316 std::optional<std::string_view> customError = std::nullopt,
317 std::optional<std::string_view> customMessage = std::nullopt
331 std::optional<std::string_view> customError = std::nullopt,
332 std::optional<std::string_view> customMessage = std::nullopt
Account not found error.
Definition Errors.hpp:241
AccountNotFoundError(std::string acct)
Construct a new Account Not Found Error object.
Definition Errors.hpp:250
char const * what() const override
Get the error message as a C string.
Definition Errors.hpp:260
Invalid parameters error.
Definition Errors.hpp:215
InvalidParamsError(std::string msg)
Construct a new Invalid Params Error object.
Definition Errors.hpp:224
char const * what() const override
Get the error message as a C string.
Definition Errors.hpp:234
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:37
ClioErrorInfo const & getErrorInfo(ClioError code)
Get the error info object from an clio-specific error code.
Definition Errors.cpp:75
static Status gOk
A globally available rpc::Status that represents a successful state.
Definition Errors.hpp:267
boost::json::object makeError(RippledError err, std::optional< std::string_view > customError, std::optional< std::string_view > customMessage)
Generate JSON from a rpc::RippledError.
Definition Errors.cpp:120
std::variant< RippledError, ClioError > CombinedError
Clio operates on a combination of Rippled and Custom Clio error codes.
Definition Errors.hpp:80
boost::json::object makeWarning(WarningCode code)
Generate JSON from a rpc::WarningCode.
Definition Errors.cpp:65
ripple::error_code_i RippledError
Clio uses compatible Rippled error codes for most RPC errors.
Definition Errors.hpp:72
WarningCode
Warning codes that can be returned by clio.
Definition Errors.hpp:188
WarningInfo const & getWarningInfo(WarningCode code)
Get the warning info object from a warning code.
Definition Errors.cpp:43
ClioError
Custom clio RPC Errors.
Definition Errors.hpp:36
Holds info about a particular ClioError.
Definition Errors.hpp:65
A status returned from any RPC handler.
Definition Errors.hpp:83
Status(CombinedError code, boost::json::object &&extraInfo)
Construct a new Status object.
Definition Errors.hpp:104
bool operator==(RippledError other) const
Returns true if the rpc::Status contains the desired rpc::RippledError.
Definition Errors.hpp:163
Status(CombinedError code)
Construct a new Status object.
Definition Errors.hpp:96
bool operator==(ClioError other) const
Returns true if the Status contains the desired ClioError.
Definition Errors.hpp:178
Status(CombinedError code, std::string error, std::string message)
Construct a new Status object.
Definition Errors.hpp:135
Status(CombinedError code, std::string message)
Construct a new Status object.
Definition Errors.hpp:124
Status(std::string message)
Construct a new Status object with a custom message.
Definition Errors.hpp:114
Holds information about a clio warning.
Definition Errors.hpp:197
constexpr WarningInfo(WarningCode code, char const *message)
Construct a new Warning Info object.
Definition Errors.hpp:206