Google Cloud C++ Client  2.7.0
C++ Client Library for Google Cloud Platform
Public Member Functions | Friends | List of all members
google::cloud::Status Class Reference

Represents success or an error with info about the error. More...

#include <google/cloud/status.h>

Public Member Functions

 Status ()
 
 ~Status ()
 
 Status (Status const &)
 
Statusoperator= (Status const &)
 
 Status (Status &&) noexcept
 
Statusoperator= (Status &&) noexcept
 
 Status (StatusCode code, std::string message, ErrorInfo info={})
 Constructs a Status with the given code and message. More...
 
bool ok () const
 
StatusCode code () const
 
std::string const & message () const
 
ErrorInfo const & error_info () const
 

Friends

bool operator== (Status const &a, Status const &b)
 
bool operator!= (Status const &a, Status const &b)
 

Detailed Description

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.

Definition at line 111 of file status.h.

Constructor & Destructor Documentation

◆ Status() [1/4]

google::cloud::Status::Status ( )

◆ ~Status()

google::cloud::Status::~Status ( )

◆ Status() [2/4]

google::cloud::Status::Status ( Status const &  )

◆ Status() [3/4]

google::cloud::Status::Status ( Status &&  )
noexcept

◆ Status() [4/4]

google::cloud::Status::Status ( StatusCode  code,
std::string  message,
ErrorInfo  info = {} 
)
explicit

Constructs a Status with the given code and message.

Ignores message if code is StatusCode::kOk.

Member Function Documentation

◆ code()

StatusCode google::cloud::Status::code ( ) const

◆ error_info()

ErrorInfo const& google::cloud::Status::error_info ( ) const

◆ message()

std::string const& google::cloud::Status::message ( ) const

◆ ok()

bool google::cloud::Status::ok ( ) const
inline

Definition at line 127 of file status.h.

◆ operator=() [1/2]

Status& google::cloud::Status::operator= ( Status &&  )
noexcept

◆ operator=() [2/2]

Status& google::cloud::Status::operator= ( Status const &  )

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( Status const &  a,
Status const &  b 
)
friend

Definition at line 135 of file status.h.

◆ operator==

bool operator== ( Status const &  a,
Status const &  b 
)
friend

Definition at line 132 of file status.h.