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,
48 RpcInvalidApiVersion = 6000,
49 RpcCommandIsMissing = 6001,
50 RpcCommandNotString = 6002,
51 RpcCommandIsEmpty = 6003,
52 RpcParamsUnparseable = 6004,
57 EtlConnectionError = 7000,
58 EtlRequestError = 7001,
59 EtlRequestTimeout = 7002,
60 EtlInvalidResponse = 7003,
66 std::string_view
const error;
67 std::string_view
const message;
86 std::optional<boost::json::object> extraInfo;
103 Status(
CombinedError code, boost::json::object&& extraInfo) : code(code), extraInfo(std::move(extraInfo)) {};
113 explicit Status(std::string message) : code(ripple::rpcUNKNOWN), message(std::move(message))
135 : code(code), error(std::move(error)), message(std::move(message))
140 operator==(
Status const& other)
const =
default;
147 operator bool()
const
149 if (
auto err = std::get_if<RippledError>(&code))
150 return *err != RippledError::rpcSUCCESS;
164 if (
auto err = std::get_if<RippledError>(&code))
165 return *err == other;
179 if (
auto err = std::get_if<ClioError>(&code))
180 return *err == other;
190 WarnRpcOutdated = 2002,
191 WarnRpcRateLimit = 2003,
192 WarnRpcDeprecated = 2004
210 std::string_view
const message =
"unknown warning";
241 std::string account_;
261 return account_.c_str();
315 std::optional<std::string_view> customError = std::nullopt,
316 std::optional<std::string_view> customMessage = std::nullopt
330 std::optional<std::string_view> customError = std::nullopt,
331 std::optional<std::string_view> customMessage = std::nullopt
Account not found error.
Definition Errors.hpp:240
AccountNotFoundError(std::string acct)
Construct a new Account Not Found Error object.
Definition Errors.hpp:249
char const * what() const override
Get the error message as a C string.
Definition Errors.hpp:259
Invalid parameters error.
Definition Errors.hpp:214
InvalidParamsError(std::string msg)
Construct a new Invalid Params Error object.
Definition Errors.hpp:223
char const * what() const override
Get the error message as a C string.
Definition Errors.hpp:233
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:36
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:266
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:79
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:71
WarningCode
Warning codes that can be returned by clio.
Definition Errors.hpp:187
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:64
A status returned from any RPC handler.
Definition Errors.hpp:82
Status(CombinedError code, boost::json::object &&extraInfo)
Construct a new Status object.
Definition Errors.hpp:103
bool operator==(RippledError other) const
Returns true if the rpc::Status contains the desired rpc::RippledError.
Definition Errors.hpp:162
Status(CombinedError code)
Construct a new Status object.
Definition Errors.hpp:95
bool operator==(ClioError other) const
Returns true if the Status contains the desired ClioError.
Definition Errors.hpp:177
Status(CombinedError code, std::string error, std::string message)
Construct a new Status object.
Definition Errors.hpp:134
Status(CombinedError code, std::string message)
Construct a new Status object.
Definition Errors.hpp:123
Status(std::string message)
Construct a new Status object with a custom message.
Definition Errors.hpp:113
Holds information about a clio warning.
Definition Errors.hpp:196
constexpr WarningInfo(WarningCode code, char const *message)
Construct a new Warning Info object.
Definition Errors.hpp:205