Class Status (2.46.0-rc) Stay organized with collections Save and categorize content based on your preferences.
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 | |
|---|---|
| Name | Description |
| Status const & |
Status(Status &&)
Move construction and assignment.
| Parameter | |
|---|---|
| Name | Description |
| Status && |
Status()
Default constructor, initializes toStatusCode::kOk.
Status(StatusCode, std::string, ErrorInfo)
Construct from a status code, message and (optional) error info.
| Parameters | |
|---|---|
| Name | Description |
code | StatusCodethe status code for the new |
message | std::stringthe message for the new |
info | ErrorInfothe |
Operators
operator=(Status const &)
Copy construction and assignment.
| Parameter | |
|---|---|
| Name | Description |
| Status const & |
| Returns | |
|---|---|
| Type | Description |
Status & | |
operator=(Status &&)
Move construction and assignment.
| Parameter | |
|---|---|
| Name | Description |
| Status && |
| Returns | |
|---|---|
| Type | Description |
Status & | |
Functions
ok() const
Returns true if the status code isStatusCode::kOk.
| Returns | |
|---|---|
| Type | Description |
bool | |
code() const
Returns the status code.
| Returns | |
|---|---|
| Type | Description |
StatusCode | |
message() const
Returns the message associated with the status.
This is always empty ifcode() isStatusCode::kOk.
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Type | Description |
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.