14#ifndef OR_TOOLS_BASE_STATUS_BUILDER_H_
15#define OR_TOOLS_BASE_STATUS_BUILDER_H_
22#include "absl/status/status.h"
23#include "absl/strings/str_cat.h"
30 : base_status_(code, {}) {}
36 : base_status_(other.base_status_),
37 ss_(other.ss_.str(),
std::ios_base::app) {}
39 base_status_ = other.base_status_;
40 ss_ = std::ostringstream(other.ss_.str(), std::ios_base::app);
45 : base_status_(
std::exchange(other.base_status_,
absl::OkStatus())),
46 ss_(
std::move(other.ss_)) {}
48 base_status_ = std::exchange(other.base_status_, absl::OkStatus());
49 ss_ = std::move(other.ss_);
53 operator absl::Status()
const {
54 const std::string annotation = ss_.str();
55 if (annotation.empty()) {
58 if (base_status_.message().empty()) {
59 return absl::Status(base_status_.code(), annotation);
61 const std::string annotated_message =
62 absl::StrCat(base_status_.message(),
"; ", annotation);
63 return absl::Status(base_status_.code(), annotated_message);
75 absl::Status base_status_;
76 std::ostringstream ss_;
StatusBuilder(const absl::Status status)
StatusBuilder & operator<<(const T &t)
StatusBuilder & operator=(StatusBuilder &&other)
StatusBuilder(const StatusBuilder &other)
StatusBuilder & SetAppend()
StatusBuilder & operator=(const StatusBuilder &other)
StatusBuilder(const absl::StatusCode code)
StatusBuilder(StatusBuilder &&other)
A collections of i/o utilities for the Graph classes in ./graph.h.
StatusBuilder ResourceExhaustedErrorBuilder()
StatusBuilder UnknownErrorBuilder()
StatusBuilder InternalErrorBuilder()
StatusBuilder UnimplementedErrorBuilder()
StatusBuilder UnavailableErrorBuilder()
StatusBuilder DataLossErrorBuilder()
StatusBuilder UnauthenticatedErrorBuilder()
StatusBuilder AbortedErrorBuilder()
StatusBuilder AlreadyExistsErrorBuilder()
StatusBuilder OutOfRangeErrorBuilder()
StatusBuilder CancelledErrorBuilder()
StatusBuilder PermissionDeniedErrorBuilder()
StatusBuilder InvalidArgumentErrorBuilder()
StatusBuilder DeadlineExceededErrorBuilder()
StatusBuilder FailedPreconditionErrorBuilder()
StatusBuilder NotFoundErrorBuilder()