absl::Status::Update

Updates the existing status with new_status provided that this->ok().

Synopsis

Declared in <absl/status/status.h>

void
Update(Status const& new_status);

Description

If the existing status already contains a non-OK error, this update has no effect and preserves the current data. Note that this behavior may change in the future to augment a current non-ok status with additional information about new_status.

Update() provides a convenient way of keeping track of the first error encountered.

Example: // Instead of "if (overall_status.ok()) overall_status = new_status" overall_status.Update(new_status);

Parameters

NameDescription
new_statusThe status to apply if *this is currently OK.