Imported Upstream version 1.26.0
[platform/upstream/grpc.git] / src / python / grpcio / grpc / _cython / _cygrpc / aio / rpc_status.pyx.pxi
1 # Copyright 2019 gRPC authors.
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 #     http://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 """Exceptions for the aio version of the RPC calls."""
15
16
17 cdef class AioRpcStatus(Exception):
18
19     # The final status of gRPC is represented by three trailing metadata:
20     # `grpc-status`, `grpc-status-message`, abd `grpc-status-details`.
21     def __cinit__(self,
22                   grpc_status_code code,
23                   str details,
24                   tuple trailing_metadata,
25                   str debug_error_string):
26         self._code = code
27         self._details = details
28         self._trailing_metadata = trailing_metadata
29         self._debug_error_string = debug_error_string
30
31     cpdef grpc_status_code code(self):
32         return self._code
33
34     cpdef str details(self):
35         return self._details
36
37     cpdef tuple trailing_metadata(self):
38         return self._trailing_metadata
39
40     cpdef str debug_error_string(self):
41         return self._debug_error_string
42
43     cdef grpc_status_code c_code(self):
44         return <grpc_status_code>self._code