Class Status (2.46.0-rc)

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-OKStatus is considered an error. Users can inspect the error using the member functions, or they can simply stream theStatus object, and it will print itself in some human readable way (the streamed format may change over time and you shouldnot depend on the specific format of a streamedStatus object remaining unchanged).

This is a regular value type that can be copied, moved, compared for equality, and streamed.

Constructors

Status(Status const &)

Copy construction and assignment.

Parameter
NameDescription
Status const &

Status(Status &&)

Move construction and assignment.

Parameter
NameDescription
Status &&

Status()

Default constructor, initializes toStatusCode::kOk.

Status(StatusCode, std::string, ErrorInfo)

Construct from a status code, message and (optional) error info.

Parameters
NameDescription
codeStatusCode

the status code for the newStatus.

messagestd::string

the message for the newStatus, ignored ifcode isStatusCode::kOk.

infoErrorInfo

theErrorInfo for the newStatus, ignored ifcode isStatusCode::kOk.

Operators

operator=(Status const &)

Copy construction and assignment.

Parameter
NameDescription
Status const &
Returns
TypeDescription
Status &

operator=(Status &&)

Move construction and assignment.

Parameter
NameDescription
Status &&
Returns
TypeDescription
Status &

Functions

ok() const

Returns true if the status code isStatusCode::kOk.

Returns
TypeDescription
bool

code() const

Returns the status code.

Returns
TypeDescription
StatusCode

message() const

Returns the message associated with the status.

This is always empty ifcode() isStatusCode::kOk.

Returns
TypeDescription
std::string const &

error_info() const

Returns the additional error info associated with the status.

This is always a default-constructed error info ifcode() isStatusCode::kOk.

Returns
TypeDescription
ErrorInfo const &

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-17 UTC.