Google Cloud C++ Client  2.1.0
C++ Client Library for Google Cloud Platform
grpc_error_delegate.h
Go to the documentation of this file.
1 // Copyright 2020 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_GRPC_ERROR_DELEGATE_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_GRPC_ERROR_DELEGATE_H
17 
18 #include "google/cloud/status.h"
19 #include "google/cloud/version.h"
20 #include <google/rpc/status.pb.h>
21 #include <grpcpp/grpcpp.h>
22 #include <string>
23 
24 namespace google {
25 namespace cloud {
27 
28 /**
29  * Creates a google::cloud::Status from a grpc::Status.
30  */
31 google::cloud::Status MakeStatusFromRpcError(grpc::Status const& status);
32 
33 /**
34  * Creates a google::cloud::Status from a grpc::StatusCode and description.
35  */
36 google::cloud::Status MakeStatusFromRpcError(grpc::StatusCode code,
37  std::string what);
38 
39 /**
40  * Creates a `google::cloud::Status` from a `google:rpc::Status` proto.
41  *
42  * Some gRPC services return the `google::rpc::Status` proto for errors. The
43  * libraries in `google-cloud-cpp` represent these errors using a
44  * `google::cloud::Status`.
45  */
46 google::cloud::Status MakeStatusFromRpcError(google::rpc::Status const& proto);
47 
49 } // namespace cloud
50 } // namespace google
51 
52 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_GRPC_ERROR_DELEGATE_H