25#include "google/protobuf/descriptor.h"
26#include "modules/common_msgs/basic_msgs/error_code.pb.h"
52 : code_(
code), msg_(msg.data()) {}
79 return (this->code_ == rh.code_) && (this->msg_ == rh.msg_);
102 return ErrorCode_Name(code_) +
": " + msg_;
113 status_pb->set_error_code(code_);
115 status_pb->set_msg(msg_);
A general class to denote the return status of an API call.
bool ok() const
check whether the return status is OK.
ErrorCode code() const
get the error code
const std::string & error_message() const
returns the error message of the status, empty if the status is OK.
std::string ToString() const
returns a string representation in a readable format.
void Save(StatusPb *status_pb)
save the error_code and error message to protobuf
static Status OK()
generate a success status.
Status(ErrorCode code=ErrorCode::OK, std::string_view msg="")
Create a status with the specified error code and msg as a human-readable string containing more deta...
bool operator==(const Status &rh) const
defines the logic of testing if two Status are equal
bool operator!=(const Status &rh) const
defines the logic of testing if two Status are unequal
std::ostream & operator<<(std::ostream &os, const Status &s)