4#include <boost/json/object.hpp>
5#include <xrpl/protocol/ErrorCodes.h>
21 RpcMalformedCurrency = 5000,
22 RpcMalformedRequest = 5001,
23 RpcMalformedOwner = 5002,
24 RpcMalformedAddress = 5003,
25 RpcUnknownOption = 5005,
26 RpcFieldNotFoundTransaction = 5006,
27 RpcMalformedOracleDocumentId = 5007,
28 RpcMalformedAuthorizedCredentials = 5008,
33 RpcInvalidApiVersion = 6000,
34 RpcCommandIsMissing = 6001,
35 RpcCommandNotString = 6002,
36 RpcCommandIsEmpty = 6003,
37 RpcParamsUnparsable = 6004,
42 EtlConnectionError = 7000,
43 EtlRequestError = 7001,
44 EtlRequestTimeout = 7002,
45 EtlInvalidResponse = 7003,
53 std::string_view
const error;
54 std::string_view
const message;
77 std::optional<boost::json::object> extraInfo;
95 : code(code), extraInfo(std::move(extraInfo)) {};
105 explicit Status(std::string message) : code(xrpl::RpcUnknown), message(std::move(message))
127 : code(code), error(std::move(error)), message(std::move(message))
139 operator bool()
const
141 if (
auto err = std::get_if<RippledError>(&code))
142 return *err != RippledError::RpcSuccess;
156 if (
auto err = std::get_if<RippledError>(&code))
157 return *err == other;
171 if (
auto err = std::get_if<ClioError>(&code))
172 return *err == other;
195 WarnRpcOutdated = 2002,
196 WarnRpcRateLimit = 2003,
197 WarnRpcDeprecated = 2004
204 constexpr WarningInfo() =
default;
217 std::string_view
const message =
"unknown warning";
241 [[nodiscard]]
char const*
252 std::string account_;
269 [[nodiscard]]
char const*
272 return account_.c_str();
328 std::optional<std::string_view> customError = std::nullopt,
329 std::optional<std::string_view> customMessage = std::nullopt
343 std::optional<std::string_view> customError = std::nullopt,
344 std::optional<std::string_view> customMessage = std::nullopt
AccountNotFoundError(std::string acct)
Construct a new Account Not Found Error object.
Definition Errors.hpp:260
char const * what() const noexcept override
Get the error message as a C string.
Definition Errors.hpp:270
InvalidParamsError(std::string msg)
Construct a new Invalid Params Error object.
Definition Errors.hpp:232
char const * what() const noexcept override
Get the error message as a C string.
Definition Errors.hpp:242
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:17
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:279
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:68
xrpl::ErrorCodeI RippledError
Clio uses compatible Rippled error codes for most RPC errors.
Definition Errors.hpp:60
boost::json::object makeWarning(WarningCode code)
Generate JSON from a rpc::WarningCode.
Definition Errors.cpp:84
WarningCode
Warning codes that can be returned by clio.
Definition Errors.hpp:192
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:19
Holds info about a particular ClioError.
Definition Errors.hpp:51
A status returned from any RPC handler.
Definition Errors.hpp:73
Status(CombinedError code, boost::json::object &&extraInfo)
Construct a new Status object.
Definition Errors.hpp:94
bool operator==(RippledError other) const
Returns true if the rpc::Status contains the desired rpc::RippledError.
Definition Errors.hpp:154
Status(CombinedError code)
Construct a new Status object.
Definition Errors.hpp:86
bool operator==(ClioError other) const
Returns true if the Status contains the desired ClioError.
Definition Errors.hpp:169
Status(CombinedError code, std::string error, std::string message)
Construct a new Status object.
Definition Errors.hpp:126
Status(CombinedError code, std::string message)
Construct a new Status object.
Definition Errors.hpp:115
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:105
Holds information about a clio warning.
Definition Errors.hpp:203
constexpr WarningInfo(WarningCode code, char const *message)
Construct a new Warning Info object.
Definition Errors.hpp:212