absl::Status::WithSourceLocation

Returns a copy of the current status, with loc appended to its location chain iff the status is non-ok and contains a non-empty message.

Synopsis

Declared in <absl/status/status.h>

Status
WithSourceLocation(absl::SourceLocation loc = absl::SourceLocation::current()) const &;

Description

Example:

if (Status status = Foo(); !status.ok()) { return status.WithSourceLocation(); }

Return Value

A copy of this status with loc appended.

Parameters

NameDescription
locThe source location to append.