A general class to denote the return status of an API call. It can either be an OK status for success, or a failure status with error message and error code enum.
More...
#include <status.h>
|
| 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 detailed information. More...
|
|
| ~Status ()=default |
|
bool | ok () const |
| check whether the return status is OK. More...
|
|
ErrorCode | code () const |
| get the error code More...
|
|
bool | operator== (const Status &rh) const |
| defines the logic of testing if two Status are equal More...
|
|
bool | operator!= (const Status &rh) const |
| defines the logic of testing if two Status are unequal More...
|
|
const std::string & | error_message () const |
| returns the error message of the status, empty if the status is OK. More...
|
|
std::string | ToString () const |
| returns a string representation in a readable format. More...
|
|
void | Save (StatusPb *status_pb) |
| save the error_code and error message to protobuf More...
|
|
A general class to denote the return status of an API call. It can either be an OK status for success, or a failure status with error message and error code enum.
◆ Status()
apollo::common::Status::Status |
( |
ErrorCode |
code = ErrorCode::OK , |
|
|
std::string_view |
msg = "" |
|
) |
| |
|
inlineexplicit |
Create a status with the specified error code and msg as a human-readable string containing more detailed information.
- Parameters
-
code | the error code. |
msg | the message associated with the error. |
◆ ~Status()
apollo::common::Status::~Status |
( |
| ) |
|
|
default |
◆ code()
ErrorCode apollo::common::Status::code |
( |
| ) |
const |
|
inline |
get the error code
- Returns
- the error code
◆ error_message()
const std::string& apollo::common::Status::error_message |
( |
| ) |
const |
|
inline |
returns the error message of the status, empty if the status is OK.
- Returns
- the error message
◆ OK()
static Status apollo::common::Status::OK |
( |
| ) |
|
|
inlinestatic |
generate a success status.
- Returns
- a success status
◆ ok()
bool apollo::common::Status::ok |
( |
| ) |
const |
|
inline |
check whether the return status is OK.
- Returns
- true if the code is ErrorCode::OK false otherwise
◆ operator!=()
bool apollo::common::Status::operator!= |
( |
const Status & |
rh | ) |
const |
|
inline |
defines the logic of testing if two Status are unequal
◆ operator==()
bool apollo::common::Status::operator== |
( |
const Status & |
rh | ) |
const |
|
inline |
defines the logic of testing if two Status are equal
◆ Save()
void apollo::common::Status::Save |
( |
StatusPb * |
status_pb | ) |
|
|
inline |
save the error_code and error message to protobuf
- Parameters
-
the | Status protobuf that will store the message. |
◆ ToString()
std::string apollo::common::Status::ToString |
( |
| ) |
const |
|
inline |
returns a string representation in a readable format.
- Returns
- the string "OK" if success. the internal error message otherwise.
The documentation for this class was generated from the following file: