Common#
Here shows some common classes and enumerations in this library.
Exceptions#
This library has following exception types:
msgpack_rpc::MsgpackRPCException
General Exceptions in this library.
Errors can be stored in
msgpack_rpc::Status
with status codes given bymsgpack_rpc::common::StatusCode
.
msgpack_rpc::clients::ServerException
Used only in clients.
For errors in a server to which a client sent a request.
msgpack_rpc::methods::MethodException
Used only in servers.
Used in implementations of methods in servers to specify errors in the method with serializable objects.
URIs#
URIs can be processed using
msgpack_rpc::addresses::URI
.
APIs of Common#
-
class MsgpackRPCException : public std::runtime_error#
Class of exceptions in cpp-msgpack-rpc library.
Public Functions
-
MsgpackRPCException(const MsgpackRPCException&) noexcept#
Copy constructor.
-
MsgpackRPCException(MsgpackRPCException&&) noexcept#
Move constructor.
-
MsgpackRPCException(StatusCode code, std::string_view message)#
Constructor.
- Parameters:
code – [in] Status code.
message – [in] Error message.
-
~MsgpackRPCException() override#
Destructor.
-
MsgpackRPCException &operator=(const MsgpackRPCException&) noexcept#
Copy assignment operator.
- Returns:
This.
-
MsgpackRPCException &operator=(MsgpackRPCException&&) noexcept#
Move assignment operator.
- Returns:
This.
-
MsgpackRPCException(const MsgpackRPCException&) noexcept#
-
class Status#
Class of statuses.
Public Functions
-
Status() noexcept#
Constructor. (Set to success.)
-
Status(StatusCode code, std::string_view message)#
Constructor.
- Parameters:
code – [in] Status code.
message – [in] Error message.
-
~Status() noexcept#
Destructor.
-
std::string_view message() const noexcept#
Get the error message.
Note
This returns empty message when this status is not an error.
- Returns:
Error message.
-
struct Data#
Internal data.
-
Status() noexcept#
-
enum class msgpack_rpc::common::StatusCode : std::uint8_t#
Enumeration of status codes.
Values:
-
enumerator SUCCESS#
Success.
-
enumerator INVALID_ARGUMENT#
Invalid arguments in functions.
-
enumerator INVALID_MESSAGE#
Failure in parsing a message.
-
enumerator TYPE_ERROR#
Invalid types in a message.
-
enumerator PRECONDITION_NOT_MET#
Pre-condition for a process is not met.
-
enumerator OPERATION_ABORTED#
Operation was aborted by user.
-
enumerator OPERATION_FAILURE#
Operation failed. (Mainly for OS calls.)
-
enumerator HOST_UNRESOLVED#
Failure in resolving a host.
-
enumerator CONNECTION_FAILURE#
Failure in connecting to an endpoint.
-
enumerator TIMEOUT#
Timeout.
-
enumerator SERVER_ERROR#
Error in servers.
-
enumerator UNEXPECTED_ERROR#
Unexpected errors. (Maybe a bug.)
-
enumerator SUCCESS#
-
class URI#
Class of URIs (Uniform Resource Identifiers) to specify endpoints in this library.
Public Functions
-
URI(std::string_view scheme, std::string_view host_or_path, std::optional<std::uint16_t> port_number = std::optional<std::uint16_t>())#
Constructor.
Note
For protocols without port numbers, port_number can be omitted.
- Parameters:
scheme – [in] Scheme.
host_or_path – [in] Host name or file path.
port_number – [in] Port number.
-
std::string_view host_or_path() const noexcept#
Get the host name or file path.
- Returns:
Host name or file path.
-
bool operator!=(const URI &right) const#
Compare with a URI.
- Parameters:
right – [in] Right-hand-side address.
- Return values:
true – Two URIs are different.
false – Two URIs are same.
-
bool operator==(const URI &right) const#
Compare with a URI.
- Parameters:
right – [in] Right-hand-side address.
- Return values:
true – Two URIs are same.
false – Two URIs are different.
-
std::optional<std::uint16_t> port_number() const noexcept#
Get the port number.
- Returns:
Port number.
-
std::string_view scheme() const noexcept#
Get the scheme.
- Returns:
Scheme.
-
URI(std::string_view scheme, std::string_view host_or_path, std::optional<std::uint16_t> port_number = std::optional<std::uint16_t>())#