@@ -79,21 +79,31 @@ class ErrorInfoBuilder {
7979 ErrorInfoBuilder (std::string file, int line, std::string function);
8080
8181 // / Adds the metadata from an error context, existing values are not replaced.
82- ErrorInfoBuilder&& WithContext(ErrorContext const & ec) & & {
82+ ErrorInfoBuilder& WithContext (ErrorContext const & ec) & {
8383 metadata_.insert (ec.begin (), ec.end ());
84- return std::move (*this );
84+ return *this ;
85+ }
86+ ErrorInfoBuilder&& WithContext(ErrorContext const & ec) && {
87+ return std::move (WithContext (ec));
8588 }
8689
8790 // / Add a metadata pair, existing values are not replaced.
91+ ErrorInfoBuilder& WithMetadata (absl::string_view key,
92+ absl::string_view value) & {
93+ metadata_.emplace (key, value);
94+ return *this ;
95+ }
8896 ErrorInfoBuilder&& WithMetadata(absl::string_view key,
8997 absl::string_view value) && {
90- metadata_.emplace (key, value);
91- return std::move (*this );
98+ return std::move (WithMetadata (std::move (key), std::move (value)));
9299 }
93100
94- ErrorInfoBuilder&& WithReason(std::string reason) & & {
101+ ErrorInfoBuilder& WithReason (std::string reason) & {
95102 reason_ = std::move (reason);
96- return std::move (*this );
103+ return *this ;
104+ }
105+ ErrorInfoBuilder&& WithReason(std::string reason) && {
106+ return std::move (WithReason (std::move (reason)));
97107 }
98108
99109 ErrorInfo Build (StatusCode code) &&;
0 commit comments