absl::StatusBuilder

Builds an absl::Status enriched with extra context, logging, and payloads.

Synopsis

Declared in <absl/status/status_builder.h>

class [[nodiscard]] StatusBuilder;

Member Functions

NameDescription
StatusBuilder [constructor]Constructors
~StatusBuilder [destructor]Destroys the builder.
operator= Assignment operators
AlsoOutputToSink Mutates the builder so that the result status will also be logged to the provided sink when this builder is converted to a status.
AttachPayload AttachPayload overloads
EmitStackTrace Mutates the builder so that a stack trace will be logged if the status is logged.
GetPayload Returns the payload associated with type_url, if present.
GetPreviousSourceLocations Returns the source locations previously recorded in the status.
HasPayload Indicates whether the result status contains any MessageSet payloads.
Log Mutates the builder so that the result status will be logged (without a stack trace) when this builder is converted to a Status.
LogError Logs the result status at severity kError.
LogEvery Mutates the builder so that the result status will be logged once per period (without a stack trace) when this builder is converted to a Status.
LogEveryN Mutates the builder so that the result status will be logged every N invocations (without a stack trace) when this builder is converted to a Status.
LogInfo Logs the result status at severity kInfo.
LogWarning Logs the result status at severity kWarning.
OnlyOutputToSink Mutates the builder so that the result status will only be logged to the provided sink when this builder is converted to a status.
SetAppend Mutates the builder so that the final additional message is appended to the original error message in the status.
SetCode Sets the status code for the status that will be returned by this StatusBuilder.
SetErrorCode Sets a non-canonical error code on the result status.
SetNoLogging Mutates the builder to disable any logging that was set using any of the logging functions below.
SetPayload Adds a payload for the status that will be returned by this StatusBuilder.
SetPrepend Mutates the builder so that the final additional message is prepended to the original error message in the status.
ToString Returns a string representation of the status this builder would produce.
VLog Mutates the builder so that the result status will be VLOGged (without a stack trace) when this builder is converted to a Status.
With Calls adaptor on this status builder to apply policies, type conversions, and/or side effects on the StatusBuilder.
code Returns the (canonical) error code for the Status created by this builder.
ok Returns true if the Status created by this builder will be ok().
source_location Returns the source location used to create this builder.
operator absl::Status Implicit conversion to Status.
operator<< Appends to the extra message that will be added to the original status.

Friends

NameDescription
absl::StatusBuilderTestTest fixture granted access to Rep's implementation.

Non-Member Functions

NameDescription
AbslInternalSetErrorCodeArgument-dependent lookup extension point that sets a StatusBuilder's error code.
HasPayloadIndicates whether the status that builder will return has a MessageSet payload.

Return Value

NOTE

The return value should not be discarded.