15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STATUS_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STATUS_H
18 #include "google/cloud/version.h"
19 #include "absl/types/optional.h"
23 #include <unordered_map>
58 std::ostream& operator<<(std::ostream& os,
StatusCode code);
62 void SetPayload(
Status&, std::string key, std::string payload);
63 absl::optional<std::string> GetPayload(
Status const&, std::string
const& key);
74 explicit ErrorInfo(std::string reason, std::string domain,
75 std::unordered_map<std::string, std::string> metadata)
76 : reason_(std::move(reason)),
77 domain_(std::move(domain)),
78 metadata_(std::move(metadata)) {}
80 std::string
const&
reason()
const {
return reason_; }
81 std::string
const&
domain()
const {
return domain_; }
82 std::unordered_map<std::string, std::string>
const&
metadata()
const {
92 std::unordered_map<std::string, std::string> metadata_;
127 bool ok()
const {
return !impl_; }
138 friend std::ostream& operator<<(std::ostream& os,
Status const& s);
142 friend void internal::SetPayload(
Status&, std::string, std::string);
143 friend absl::optional<std::string> internal::GetPayload(
Status const&,
148 std::unique_ptr<Impl> impl_;