status_conversion.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
20 
22 
24 
26  switch (status) {
27  case GRPC_STATUS_OK:
28  return GRPC_HTTP2_NO_ERROR;
30  return GRPC_HTTP2_CANCEL;
32  return GRPC_HTTP2_CANCEL;
39  default:
41  }
42 }
43 
46  switch (error) {
48  /* should never be received */
49  return GRPC_STATUS_INTERNAL;
50  case GRPC_HTTP2_CANCEL:
51  /* http2 cancel translates to STATUS_CANCELLED iff deadline hasn't been
52  * exceeded */
53  return grpc_core::ExecCtx::Get()->Now() > deadline
62  default:
63  return GRPC_STATUS_INTERNAL;
64  }
65 }
66 
68  switch (status) {
69  /* these HTTP2 status codes are called out explicitly in status.proto */
70  case 200:
71  return GRPC_STATUS_OK;
72  case 400:
73  return GRPC_STATUS_INTERNAL;
74  case 401:
76  case 403:
78  case 404:
80  case 429:
82  case 502:
84  case 503:
86  case 504:
88  /* everything else is unknown */
89  default:
90  return GRPC_STATUS_UNKNOWN;
91  }
92 }
93 
94 int grpc_status_to_http2_status(grpc_status_code /*status*/) { return 200; }
grpc_status_to_http2_status
int grpc_status_to_http2_status(grpc_status_code)
Definition: status_conversion.cc:94
GRPC_HTTP2_CANCEL
@ GRPC_HTTP2_CANCEL
Definition: http2_errors.h:32
GRPC_STATUS_UNAVAILABLE
@ GRPC_STATUS_UNAVAILABLE
Definition: include/grpc/impl/codegen/status.h:143
GRPC_STATUS_UNAUTHENTICATED
@ GRPC_STATUS_UNAUTHENTICATED
Definition: include/grpc/impl/codegen/status.h:72
GRPC_HTTP2_INADEQUATE_SECURITY
@ GRPC_HTTP2_INADEQUATE_SECURITY
Definition: http2_errors.h:36
GRPC_HTTP2_ENHANCE_YOUR_CALM
@ GRPC_HTTP2_ENHANCE_YOUR_CALM
Definition: http2_errors.h:35
grpc_core::Timestamp
Definition: src/core/lib/gprpp/time.h:62
GRPC_STATUS_PERMISSION_DENIED
@ GRPC_STATUS_PERMISSION_DENIED
Definition: include/grpc/impl/codegen/status.h:68
error
grpc_error_handle error
Definition: retry_filter.cc:499
grpc_status_code
grpc_status_code
Definition: include/grpc/impl/codegen/status.h:28
status
absl::Status status
Definition: rls.cc:251
GRPC_STATUS_CANCELLED
@ GRPC_STATUS_CANCELLED
Definition: include/grpc/impl/codegen/status.h:33
GRPC_STATUS_DEADLINE_EXCEEDED
@ GRPC_STATUS_DEADLINE_EXCEEDED
Definition: include/grpc/impl/codegen/status.h:53
GRPC_STATUS_RESOURCE_EXHAUSTED
@ GRPC_STATUS_RESOURCE_EXHAUSTED
Definition: include/grpc/impl/codegen/status.h:76
GRPC_STATUS_OK
@ GRPC_STATUS_OK
Definition: include/grpc/impl/codegen/status.h:30
grpc_status_to_http2_error
grpc_http2_error_code grpc_status_to_http2_error(grpc_status_code status)
Definition: status_conversion.cc:25
GRPC_HTTP2_INTERNAL_ERROR
@ GRPC_HTTP2_INTERNAL_ERROR
Definition: http2_errors.h:26
grpc_http2_status_to_grpc_status
grpc_status_code grpc_http2_status_to_grpc_status(int status)
Definition: status_conversion.cc:67
GRPC_HTTP2_REFUSED_STREAM
@ GRPC_HTTP2_REFUSED_STREAM
Definition: http2_errors.h:31
grpc_http2_error_code
grpc_http2_error_code
Definition: http2_errors.h:23
exec_ctx.h
GRPC_STATUS_UNIMPLEMENTED
@ GRPC_STATUS_UNIMPLEMENTED
Definition: include/grpc/impl/codegen/status.h:124
GRPC_STATUS_INTERNAL
@ GRPC_STATUS_INTERNAL
Definition: include/grpc/impl/codegen/status.h:129
status_conversion.h
grpc_core::ExecCtx::Now
Timestamp Now()
Definition: exec_ctx.cc:90
GRPC_HTTP2_NO_ERROR
@ GRPC_HTTP2_NO_ERROR
Definition: http2_errors.h:24
grpc_http2_error_to_grpc_status
grpc_status_code grpc_http2_error_to_grpc_status(grpc_http2_error_code error, grpc_core::Timestamp deadline)
Definition: status_conversion.cc:44
grpc_core::ExecCtx::Get
static ExecCtx * Get()
Definition: exec_ctx.h:205
GRPC_STATUS_UNKNOWN
@ GRPC_STATUS_UNKNOWN
Definition: include/grpc/impl/codegen/status.h:40
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:17