rippled
|
Status represents the results of an operation that might fail. More...
Public Types | |
enum | Type { Type::none, Type::TER, Type::error_code_i } |
using | Code = int |
using | Strings = std::vector< std::string > |
Public Member Functions | |
Status ()=default | |
template<typename T , typename = std::enable_if_t<std::is_integral<T>::value>> | |
Status (T code, Strings d={}) | |
Status (TER ter, Strings d={}) | |
Status (error_code_i e, Strings d={}) | |
Status (error_code_i e, std::string const &s) | |
std::string | codeString () const |
operator bool () const | |
Returns true if the Status is not OK. More... | |
bool | operator! () const |
Returns true if the Status is OK. More... | |
TER | toTER () const |
Returns the Status as a TER. More... | |
error_code_i | toErrorCode () const |
Returns the Status as an error_code_i. More... | |
template<class Object > | |
void | inject (Object &object) const |
Apply the Status to a JsonObject. More... | |
Strings const & | messages () const |
std::string | message () const |
Return the first message, if any. More... | |
Type | type () const |
std::string | toString () const |
void | fillJson (Json::Value &) |
Fill a Json::Value with an RPC 2.0 response. More... | |
T | what (T... args) |
Static Public Attributes | |
static constexpr Code | OK = 0 |
Private Attributes | |
Type | type_ = Type::none |
Code | code_ = OK |
Strings | messages_ |
Status represents the results of an operation that might fail.
It wraps the legacy codes TER and error_code_i, providing both a uniform interface and a way to attach additional information to existing status returns.
A Status can also be used to fill a Json::Value with a JSON-RPC 2.0 error response: see http://www.jsonrpc.org/specification#error_object
using ripple::RPC::Status::Code = int |
|
strong |
|
default |
ripple::RPC::Status::Status | ( | T | code, |
Strings | d = {} |
||
) |
ripple::RPC::Status::Status | ( | error_code_i | e, |
Strings | d = {} |
||
) |
ripple::RPC::Status::Status | ( | error_code_i | e, |
std::string const & | s | ||
) |
std::string ripple::RPC::Status::codeString | ( | ) | const |
Definition at line 27 of file Status.cpp.
ripple::RPC::Status::operator bool | ( | ) | const |
bool ripple::RPC::Status::operator! | ( | ) | const |
TER ripple::RPC::Status::toTER | ( | ) | const |
error_code_i ripple::RPC::Status::toErrorCode | ( | ) | const |
Returns the Status as an error_code_i.
This may only be called if type() == Type::error_code_i.
void ripple::RPC::Status::inject | ( | Object & | object | ) | const |
std::string ripple::RPC::Status::message | ( | ) | const |
Return the first message, if any.
Definition at line 78 of file Status.cpp.
std::string ripple::RPC::Status::toString | ( | ) | const |
Definition at line 92 of file Status.cpp.
void ripple::RPC::Status::fillJson | ( | Json::Value & | value | ) |
Fill a Json::Value with an RPC 2.0 response.
If the Status is OK, fillJson has no effect. Not currently used.
Definition at line 59 of file Status.cpp.
|
private |