4#include <boost/json/object.hpp>
5#include <xrpl/protocol/ErrorCodes.h>
19 RpcMalformedCurrency = 5000,
20 RpcMalformedRequest = 5001,
21 RpcMalformedOwner = 5002,
22 RpcMalformedAddress = 5003,
23 RpcUnknownOption = 5005,
24 RpcFieldNotFoundTransaction = 5006,
25 RpcMalformedOracleDocumentId = 5007,
26 RpcMalformedAuthorizedCredentials = 5008,
31 RpcInvalidApiVersion = 6000,
32 RpcCommandIsMissing = 6001,
33 RpcCommandNotString = 6002,
34 RpcCommandIsEmpty = 6003,
35 RpcParamsUnparsable = 6004,
40 EtlConnectionError = 7000,
41 EtlRequestError = 7001,
42 EtlRequestTimeout = 7002,
43 EtlInvalidResponse = 7003,
49 std::string_view
const error;
50 std::string_view
const message;
69 std::optional<boost::json::object> extraInfo;
87 : code(code), extraInfo(std::move(extraInfo)) {};
97 explicit Status(std::string message) : code(ripple::rpcUNKNOWN), message(std::move(message))
119 : code(code), error(std::move(error)), message(std::move(message))
131 operator bool()
const
133 if (
auto err = std::get_if<RippledError>(&code))
134 return *err != RippledError::rpcSUCCESS;
148 if (
auto err = std::get_if<RippledError>(&code))
149 return *err == other;
163 if (
auto err = std::get_if<ClioError>(&code))
164 return *err == other;
184 WarnRpcOutdated = 2002,
185 WarnRpcRateLimit = 2003,
186 WarnRpcDeprecated = 2004
191 constexpr WarningInfo() =
default;
204 std::string_view
const message =
"unknown warning";
235 std::string account_;
255 return account_.c_str();
309 std::optional<std::string_view> customError = std::nullopt,
310 std::optional<std::string_view> customMessage = std::nullopt
324 std::optional<std::string_view> customError = std::nullopt,
325 std::optional<std::string_view> customMessage = std::nullopt
AccountNotFoundError(std::string acct)
Construct a new Account Not Found Error object.
Definition Errors.hpp:243
char const * what() const override
Get the error message as a C string.
Definition Errors.hpp:253
InvalidParamsError(std::string msg)
Construct a new Invalid Params Error object.
Definition Errors.hpp:217
char const * what() const override
Get the error message as a C string.
Definition Errors.hpp:227
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:18
ClioErrorInfo const & getErrorInfo(ClioError code)
Get the error info object from an clio-specific error code.
Definition Errors.cpp:94
static Status gOk
A globally available rpc::Status that represents a successful state.
Definition Errors.hpp:260
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:160
std::variant< RippledError, ClioError > CombinedError
Clio operates on a combination of Rippled and Custom Clio error codes.
Definition Errors.hpp:62
boost::json::object makeWarning(WarningCode code)
Generate JSON from a rpc::WarningCode.
Definition Errors.cpp:84
ripple::error_code_i RippledError
Clio uses compatible Rippled error codes for most RPC errors.
Definition Errors.hpp:54
WarningCode
Warning codes that can be returned by clio.
Definition Errors.hpp:181
WarningInfo const & getWarningInfo(WarningCode code)
Get the warning info object from a warning code.
Definition Errors.cpp:61
bool operator==(MaybeError const &lhs, MaybeError const &rhs)
Check if two MaybeError objects are equal.
Definition Types.hpp:46
ClioError
Custom clio RPC Errors.
Definition Errors.hpp:17
Holds info about a particular ClioError.
Definition Errors.hpp:47
A status returned from any RPC handler.
Definition Errors.hpp:65
Status(CombinedError code, boost::json::object &&extraInfo)
Construct a new Status object.
Definition Errors.hpp:86
bool operator==(RippledError other) const
Returns true if the rpc::Status contains the desired rpc::RippledError.
Definition Errors.hpp:146
Status(CombinedError code)
Construct a new Status object.
Definition Errors.hpp:78
bool operator==(ClioError other) const
Returns true if the Status contains the desired ClioError.
Definition Errors.hpp:161
Status(CombinedError code, std::string error, std::string message)
Construct a new Status object.
Definition Errors.hpp:118
Status(CombinedError code, std::string message)
Construct a new Status object.
Definition Errors.hpp:107
friend std::ostream & operator<<(std::ostream &stream, Status const &status)
Custom output stream for Status.
Definition Errors.cpp:26
Status(std::string message)
Construct a new Status object with a custom message.
Definition Errors.hpp:97
Holds information about a clio warning.
Definition Errors.hpp:190
constexpr WarningInfo(WarningCode code, char const *message)
Construct a new Warning Info object.
Definition Errors.hpp:199