Class Status (2.23.0)

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.

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 to StatusCode::kOk.

Status(StatusCode, std::string, ErrorInfo)

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

Parameters
Name Description
code StatusCode

the status code for the new Status.

message std::string

the message for the new Status, ignored if code is StatusCode::kOk.

info ErrorInfo

the ErrorInfo for the new Status, ignored if code is StatusCode::kOk.

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 is StatusCode::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 if code() is StatusCode::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 if code() is StatusCode::kOk.

Returns
Type Description
ErrorInfo const &