class StatusBuilder

Defined at line 35 of file ../../third_party/cobalt/src/lib/util/status_builder.h

Public Methods

Status Build ()

Converts the |StatusBuilder| into a |Status| object.

void StatusBuilder ()

Defined at line 37 of file ../../third_party/cobalt/src/lib/util/status_builder.h

void ~StatusBuilder ()

Defined at line 38 of file ../../third_party/cobalt/src/lib/util/status_builder.h

void StatusBuilder (const StatusBuilder & sb)

Make StatusBuilder move-only.

Defined at line 54 of file ../../third_party/cobalt/src/lib/util/status_builder.h

StatusBuilder & operator= (const StatusBuilder & sb)

Defined at line 55 of file ../../third_party/cobalt/src/lib/util/status_builder.h

void StatusBuilder (StatusBuilder && )

Defined at line 56 of file ../../third_party/cobalt/src/lib/util/status_builder.h

StatusBuilder & operator= (StatusBuilder && )

Defined at line 57 of file ../../third_party/cobalt/src/lib/util/status_builder.h

StatusBuilder & SetCode (StatusCode status_code)

Defined at line 62 of file ../../third_party/cobalt/src/lib/util/status_builder.h

StatusBuilder && SetCode (StatusCode status_code)

"Owned" (rvalue) version of SetCode that doesn}'t convert StatusBuilder into a reference

(lvalue)

Defined at line 68 of file ../../third_party/cobalt/src/lib/util/status_builder.h

StatusBuilder & Log (LogLevel level)

These methods define where the status should be logged on construction. If

none of these methods are called, or |LogLevel::NO_LOGGING| is provided to

the |Log| method, nothing will be logged when the |StatusBuilder| is

converted into a |Status|.

Defined at line 84 of file ../../third_party/cobalt/src/lib/util/status_builder.h

StatusBuilder && Log (LogLevel level)

"Owned" (rvalue) version of Log that does not convert StatusBuilder to a reference (lvalue)

Defined at line 89 of file ../../third_party/cobalt/src/lib/util/status_builder.h

StatusBuilder & LogError ()

When the |Status| object is created, send it to LOG(ERROR).

Defined at line 92 of file ../../third_party/cobalt/src/lib/util/status_builder.h

StatusBuilder && LogError ()

"Owned" (rvalue) version of LogError that does not convert StatusBuilder to a reference

(lvalue)

Defined at line 95 of file ../../third_party/cobalt/src/lib/util/status_builder.h

StatusBuilder & LogWarning ()

When the |Status| object is created, send it to LOG(WARNING)

Defined at line 98 of file ../../third_party/cobalt/src/lib/util/status_builder.h

StatusBuilder && LogWarning ()

"Owned" (rvalue) version of LogWarning that does not convert StatusBuilder to a reference

(lvalue)

Defined at line 101 of file ../../third_party/cobalt/src/lib/util/status_builder.h

StatusBuilder & LogInfo ()

When the |Status| object is created, send it to LOG(INFO)

Defined at line 104 of file ../../third_party/cobalt/src/lib/util/status_builder.h

StatusBuilder && LogInfo ()

"Owned" (rvalue) version of LogInfo that does not convert StatusBuilder to a reference (lvalue)

Defined at line 106 of file ../../third_party/cobalt/src/lib/util/status_builder.h

void StatusBuilder (const Status & original_status, util::SourceLocation location)

Create a StatusBuilder based on |original_status|. Used to add extra contextual information to

the status.

void StatusBuilder (StatusCode status_code, util::SourceLocation location)

Create a StatusBuilder for a given |status_code|.

void StatusBuilder (StatusCode status_code, const std::string & initial_message, util::SourceLocation location)

Create a StatusBuilder for a given |status_code| with an |initial message|.

template <typename V>
StatusBuilder & WithContext (const std::string & key, const V & value)

WithContext can be used to easily add contextual information to a Status

while maintaining the error_code, and error_message.

Example:

Status result = DoSomething();

if (!status.ok()) {

// This will add 'Metric=

<metric

_id>' to the error_details string.

return util::StatusBuilder(result).WithContext("Metric", metric_id);

}

Defined at line 118 of file ../../third_party/cobalt/src/lib/util/status_builder.h

template <typename V>
StatusBuilder && WithContext (const std::string & key, const V & value)

"Owned" (rvalue) version of WithContext that doesn't convert the StatusBuilder into a reference

(lvalue).

Defined at line 135 of file ../../third_party/cobalt/src/lib/util/status_builder.h

template <typename V>
StatusBuilder & WithContexts (const V & v)

Single argument version of WithContext for types where there is a ContextFormatter defined.

Defined at line 141 of file ../../third_party/cobalt/src/lib/util/status_builder.h

template <typename V>
StatusBuilder && WithContexts (const V & v)

"Owned" (rvalue) version of the above method that doesn't convert StatusBuilder into reference

(lvalue).

Defined at line 150 of file ../../third_party/cobalt/src/lib/util/status_builder.h

template <typename V, typename... ContextValues>
StatusBuilder & WithContexts (const V & v, ContextValues &&... args)

Variadic version of WithContexts.

Defined at line 156 of file ../../third_party/cobalt/src/lib/util/status_builder.h

template <typename V, typename... ContextValues>
StatusBuilder && WithContexts (const V & v, ContextValues &&... args)

"Owned" (rvalue) version of the above method that doesn't convert StatusBuilder into reference

(lvalue).

Defined at line 163 of file ../../third_party/cobalt/src/lib/util/status_builder.h

template <typename V>
StatusBuilder & AppendMsg (const V & value)

AppendMsg appends the value to the error_message;

Defined at line 169 of file ../../third_party/cobalt/src/lib/util/status_builder.h

template <typename V>
StatusBuilder && AppendMsg (const V & value)

"Owned" (rvalue) version of AppendMsg that doesn't convert the StatusBuilder into a reference

(lvalue).

Defined at line 182 of file ../../third_party/cobalt/src/lib/util/status_builder.h

Enumerations

enum LogLevel
Name Value
INFO 0
WARNING 1
ERROR 2
NO_LOGGING 3

LogLevel is used to denote where the status should be logged on construction.

Defined at line 73 of file ../../third_party/cobalt/src/lib/util/status_builder.h