Status is a thin, zero-cost abstraction around the pw_Status enum. It initializes to pw::OkStatus() by default and adds ok() and str() methods. Status implicitly converts from pw_Status; use code() to convert a Status to pw_Status.
An OK status is created by the pw::OkStatus() function or by the default Status constructor. Non-OK Status is created with a static member function that corresponds with the status code. Example:
A non-OK Status may carry an optional error message created with PW_STATUS_MSG (e.g. Status::NotFound(PW_STATUS_MSG("No such key"))). Messages are discarded at compile time unless PW_STATUS_CFG_MESSAGES enables them. Unlike absl::Status, equality comparisons (== and !=) consider only the status code and ignore messages.
Public Types | |
| using | Code = pw_Status |
Public Types inherited from pw::StatusBase< Status, PW_STATUS_OK > | |
| using | Code = decltype(kOkCode) |
| The underlying status code type. | |
Public Member Functions | |
| constexpr | Status (Code code=PW_STATUS_OK) noexcept |
| constexpr | Status (Code code, Message message) noexcept |
Creates a status with a PW_STATUS_MSG. | |
| constexpr | Status (const Status &)=default |
| constexpr Status & | operator= (const Status &)=default |
| constexpr | Status (Status &&)=default |
| constexpr Status & | operator= (Status &&)=default |
| constexpr bool | IsCancelled () const noexcept |
| constexpr bool | IsUnknown () const noexcept |
| constexpr bool | IsInvalidArgument () const noexcept |
| constexpr bool | IsDeadlineExceeded () const noexcept |
| constexpr bool | IsNotFound () const noexcept |
| constexpr bool | IsAlreadyExists () const noexcept |
| constexpr bool | IsPermissionDenied () const noexcept |
| constexpr bool | IsResourceExhausted () const noexcept |
| constexpr bool | IsFailedPrecondition () const noexcept |
| constexpr bool | IsAborted () const noexcept |
| constexpr bool | IsOutOfRange () const noexcept |
| constexpr bool | IsUnimplemented () const noexcept |
| constexpr bool | IsInternal () const noexcept |
| constexpr bool | IsUnavailable () const noexcept |
| constexpr bool | IsDataLoss () const noexcept |
| constexpr bool | IsUnauthenticated () const noexcept |
Public Member Functions inherited from pw::StatusBase< Status, PW_STATUS_OK > | |
| constexpr bool | ok () const noexcept |
| Returns true if the status is the OK code. | |
| constexpr Code | code () const noexcept |
| Returns the underlying status code. | |
| constexpr bool | has_message () const noexcept |
| constexpr Message | message () const noexcept |
| constexpr void | Update (Status other) noexcept |
| constexpr void | IgnoreError () const noexcept |
| Ignores any errors, suppressing unused-result warnings. | |
| constexpr const char * | str () const |
Static Public Member Functions | |
| static constexpr Status | Cancelled () noexcept |
| static constexpr Status | Unknown () noexcept |
| static constexpr Status | InvalidArgument () noexcept |
| static constexpr Status | DeadlineExceeded () noexcept |
| static constexpr Status | NotFound () noexcept |
| static constexpr Status | AlreadyExists () noexcept |
| static constexpr Status | PermissionDenied () noexcept |
| static constexpr Status | ResourceExhausted () noexcept |
| static constexpr Status | FailedPrecondition () noexcept |
| static constexpr Status | Aborted () noexcept |
| static constexpr Status | OutOfRange () noexcept |
| static constexpr Status | Unimplemented () noexcept |
| static constexpr Status | Internal () noexcept |
| static constexpr Status | Unavailable () noexcept |
| static constexpr Status | DataLoss () noexcept |
| static constexpr Status | Unauthenticated () noexcept |
Factories with a message | |
Overloads of the functions above that attach a | |
| static constexpr Status | Cancelled (Message message) noexcept |
| static constexpr Status | Unknown (Message message) noexcept |
| static constexpr Status | InvalidArgument (Message message) noexcept |
| static constexpr Status | DeadlineExceeded (Message message) noexcept |
| static constexpr Status | NotFound (Message message) noexcept |
| static constexpr Status | AlreadyExists (Message message) noexcept |
| static constexpr Status | PermissionDenied (Message message) noexcept |
| static constexpr Status | ResourceExhausted (Message message) noexcept |
| static constexpr Status | FailedPrecondition (Message message) noexcept |
| static constexpr Status | Aborted (Message message) noexcept |
| static constexpr Status | OutOfRange (Message message) noexcept |
| static constexpr Status | Unimplemented (Message message) noexcept |
| static constexpr Status | Internal (Message message) noexcept |
| static constexpr Status | Unavailable (Message message) noexcept |
| static constexpr Status | DataLoss (Message message) noexcept |
| static constexpr Status | Unauthenticated (Message message) noexcept |
Additional Inherited Members | |
Protected Member Functions inherited from pw::StatusBase< Status, PW_STATUS_OK > | |
| constexpr | StatusBase () noexcept=default |
Defaults to kOkCode (ok() == true). | |
| constexpr | StatusBase (Code code) noexcept |
| Explicitly construct from the underlying code. | |
| constexpr | StatusBase (Code code, Message message) noexcept |
| constexpr | StatusBase (const StatusBase &)=default |
| constexpr | StatusBase (StatusBase &&)=default |
| constexpr StatusBase & | operator= (const StatusBase &)=default |
| constexpr StatusBase & | operator= (StatusBase &&)=default |
|
inlineconstexprnoexcept |
Statuses are created with a Status::Code.
code is a valid status code. Use pw::StatusFromCodeOrUnknown to convert integers that may not be.
|
inlinestaticconstexprnoexcept |
Operation aborted due to e.g. concurrency issue or failed transaction.
ABORTED). The C++ API for this code is Status::Aborted() (or status.IsAborted()) and the C API is PW_STATUS_ABORTED. See ABORTED for details on interacting with this status code in other languages.
|
inlinestaticconstexprnoexcept |
The entity that the caller requested to create is already present.
ALREADY_EXISTS). The C++ API for this code is Status::AlreadyExists() (or status.IsAlreadyExists()) and the C API is PW_STATUS_ALREADY_EXISTS. See ALREADY_EXISTS for details on interacting with this status code in other languages.
|
inlinestaticconstexprnoexcept |
Operation was cancelled, typically by the caller.
CANCELLED). The C++ API for this code is Status::Cancelled() (or status.IsCancelled()) and the C API is PW_STATUS_CANCELLED. See CANCELLED for details on interacting with this status code in other languages.
|
inlinestaticconstexprnoexcept |
Unrecoverable data loss occurred while completing the requested operation.
DATA_LOSS). The C++ API for this code is Status::DataLoss() (or status.IsDataLoss()) and the C API is PW_STATUS_DATA_LOSS. See DATA_LOSS for details on interacting with this status code in other languages.
|
inlinestaticconstexprnoexcept |
Deadline passed before operation completed.
DEADLINE_EXCEEDED). The C++ API for this code is Status::DeadlineExceeded() (or status.IsDeadlineExceeded()) and the C API is PW_STATUS_DEADLINE_EXCEEDED. See DEADLINE_EXCEEDED for details on interacting with this status code in other languages.
|
inlinestaticconstexprnoexcept |
System isn’t in the required state; e.g. deleting a non-empty directory.
FAILED_PRECONDITION). The C++ API for this code is Status::FailedPrecondition() (or status.IsFailedPrecondition()) and the C API is PW_STATUS_PERMISSION_DENIED. See PERMISSION_DENIED for details on interacting with this status code in other languages.
|
inlinestaticconstexprnoexcept |
Internal error occurred; e.g. system invariants were violated.
INTERNAL). The C++ API for this code is Status::Internal() (or status.IsInternal()) and the C API is PW_STATUS_INTERNAL. See INTERNAL for details on interacting with this status code in other languages.
|
inlinestaticconstexprnoexcept |
Argument was malformed; e.g. invalid characters when parsing integer.
INVALID_ARGUMENT). The C++ API for this code is Status::InvalidArgument() (or status.IsInvalidArgument()) and the C API is PW_STATUS_INVALID_ARGUMENT. See INVALID_ARGUMENT for details on interacting with this status code in other languages.
|
inlineconstexprnoexcept |
true if the status of this instance is ABORTED.
|
inlineconstexprnoexcept |
true if the status of this instance is ALREADY_EXISTS.
|
inlineconstexprnoexcept |
true if the status of this instance is CANCELLED.
|
inlineconstexprnoexcept |
true if the status of this instance is DATA_LOSS.
|
inlineconstexprnoexcept |
true if the status of this instance is DEADLINE_EXCEEDED.
|
inlineconstexprnoexcept |
true if the status of this instance is FAILED_PRECONDITION.
|
inlineconstexprnoexcept |
true if the status of this instance is INTERNAL.
|
inlineconstexprnoexcept |
true if the status of this instance is INVALID_ARGUMENT.
|
inlineconstexprnoexcept |
true if the status of this instance is NOT_FOUND.
|
inlineconstexprnoexcept |
true if the status of this instance is OUT_OF_RANGE.
|
inlineconstexprnoexcept |
true if the status of this instance is PERMISSION_DENIED.
|
inlineconstexprnoexcept |
true if the status of this instance is RESOURCE_EXHAUSTED.
|
inlineconstexprnoexcept |
true if the status of this instance is UNAUTHENTICATED.
|
inlineconstexprnoexcept |
true if the status of this instance is UNAVAILABLE.
|
inlineconstexprnoexcept |
true if the status of this instance is UNIMPLEMENTED.
|
inlineconstexprnoexcept |
true if the status of this instance is UNKNOWN.
|
inlinestaticconstexprnoexcept |
The entity that the caller requested (e.g. file or directory) is not found.
NOT_FOUND). The C++ API for this code is Status::NotFound() (or status.IsNotFound()) and the C API is PW_STATUS_NOT_FOUND. See NOT_FOUND for details on interacting with this status code in other languages.
|
inlinestaticconstexprnoexcept |
Operation attempted out of range; e.g. seeking past end of file.
OUT_OF_RANGE). The C++ API for this code is Status::OutOfRange() (or status.IsOutOfRange()) and the C API is PW_STATUS_OUT_OF_RANGE. See OUT_OF_RANGE for details on interacting with this status code in other languages.
|
inlinestaticconstexprnoexcept |
Caller lacks permission to execute action.
PERMISSION_DENIED). The C++ API for this code is Status::PermissionDenied() (or status.IsPermissionDenied()) and the C API is PW_STATUS_PERMISSION_DENIED. See PERMISSION_DENIED for details on interacting with this status code in other languages.
|
inlinestaticconstexprnoexcept |
Insufficient resources to complete operation; e.g. supplied buffer is too small.
RESOURCE_EXHAUSTED). The C++ API for this code is Status::ResourceExhausted() (or status.IsResourceExhausted()) and the C API is PW_STATUS_RESOURCE_EXHAUSTED. See RESOURCE_EXHAUSTED for details on interacting with this status code in other languages.
|
inlinestaticconstexprnoexcept |
Caller does not have valid authentication credentials for the operation.
UNAUTHENTICATED). The C++ API for this code is Status::Unauthenticated() (or status.IsUnauthenticated()) and the C API is PW_STATUS_UNAUTHENTICATED. See UNAUTHENTICATED for details on interacting with this status code in other languages.
|
inlinestaticconstexprnoexcept |
Requested operation can’t finish now, but may at a later time.
UNAVAILABLE). The C++ API for this code is Status::Unavailable() (or status.IsUnavailable()) and the C API is PW_STATUS_UNAVAILABLE. See UNAVAILABLE for details on interacting with this status code in other languages.
|
inlinestaticconstexprnoexcept |
Operation isn’t implemented or supported.
UNIMPLEMENTED). The C++ API for this code is Status::Unimplemented() (or status.IsUnimplemented()) and the C API is PW_STATUS_UNIMPLEMENTED. See UNIMPLEMENTED for details on interacting with this status code in other languages.
|
inlinestaticconstexprnoexcept |
Unknown error occurred. Avoid this code when possible.
UNKNOWN). The C++ API for this code is Status::Unknown() (or status.IsUnknown()) and the C API is PW_STATUS_UNKNOWN. See UNKNOWN for details on interacting with this status code in other languages.