Google Cloud C++ Client 2.10.1
C++ Client Library for Google Cloud Platform
|
Represents success or an error with info about the error. More...
#include <google/cloud/status.h>
Public Member Functions | |
Status () | |
Default constructor, initializes to StatusCode::kOk . More... | |
~Status () | |
Destructor. More... | |
Status (StatusCode code, std::string message, ErrorInfo info={}) | |
Construct from a status code, message and (optional) error info. More... | |
bool | ok () const |
Returns true if the status code is StatusCode::kOk . More... | |
StatusCode | code () const |
Returns the status code. More... | |
std::string const & | message () const |
Returns the message associated with the status. More... | |
ErrorInfo const & | error_info () const |
Returns the additional error info associated with the status. More... | |
Copy construction and assignment. | |
Status (Status const &) | |
Status & | operator= (Status const &) |
Move construction and assignment. | |
Status (Status &&) noexcept | |
Status & | operator= (Status &&) noexcept |
Friends | |
bool | operator== (Status const &a, Status const &b) |
bool | operator!= (Status const &a, Status const &b) |
Represents success or an error with info about the error.
This class is typically used to indicate whether or not a function or other operation completed successfully. Success is indicated by an "OK" status. OK statuses will have .code() == StatusCode::kOk
and .ok() == true
, with all other properties having empty values. All OK statuses are equal. Any non-OK Status
is considered an error. Users can inspect the error using the member functions, or they can simply stream the Status
object, and it will print itself in some human readable way (the streamed format may change over time and you should not depend on the specific format of a streamed Status
object remaining unchanged).
This is a regular value type that can be copied, moved, compared for equality, and streamed.
google::cloud::Status::Status | ( | ) |
Default constructor, initializes to StatusCode::kOk
.
google::cloud::Status::~Status | ( | ) |
Destructor.
google::cloud::Status::Status | ( | Status const & | ) |
|
noexcept |
|
explicit |
Construct from a status code, message and (optional) error info.
code | the status code for the new Status . |
message | the message for the new Status , ignored if code is StatusCode::kOk . |
info | the ErrorInfo for the new Status , ignored if code is SStatusCode::kOk . |
StatusCode google::cloud::Status::code | ( | ) | const |
Returns the status code.
ErrorInfo const & google::cloud::Status::error_info | ( | ) | const |
Returns the additional error info associated with the status.
This is always a default-constructed error info if code()
is StatusCode::kOk
.
std::string const & google::cloud::Status::message | ( | ) | const |
Returns the message associated with the status.
This is always empty if code()
is StatusCode::kOk
.
|
inline |
Returns true if the status code is StatusCode::kOk
.