absl::Status::Status

Creates a status in the canonical error space with the specified absl::StatusCode and error message. If code == absl::StatusCode::kOk, msg is ignored and an object identical to an OK status is constructed.

Synopsis

Declared in <absl/status/status.h>

Status(
    absl::StatusCode code,
    std::string_view msg,
    absl::SourceLocation loc = SourceLocation::current());

Description

The msg string must be in UTF-8. The implementation may complain (e.g., by printing a warning) if it is not.

The loc is the SourceLocation of the callsite. It will be stored in the Status iff code != absl::StatusCode::kOk and !msg.empty().

Parameters

NameDescription
codeThe canonical error code for the status.
msgThe UTF-8 error message.
locThe source location of the callsite.