Skip to content

Commit abfdbf6

Browse files
author
Xudong Ma
committed
OkHttp: sync error map with gRpc spec.
1 parent a36f4af commit abfdbf6

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

okhttp/src/main/java/io/grpc/transport/okhttp/OkHttpClientTransport.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,10 @@ class OkHttpClientTransport implements ClientTransport {
9696

9797
static {
9898
Map<ErrorCode, Status> errorToStatus = new HashMap<ErrorCode, Status>();
99-
errorToStatus.put(ErrorCode.NO_ERROR, Status.OK);
99+
errorToStatus.put(ErrorCode.NO_ERROR,
100+
Status.INTERNAL.withDescription("No error: A GRPC status of OK should have been sent"));
100101
errorToStatus.put(ErrorCode.PROTOCOL_ERROR,
101102
Status.INTERNAL.withDescription("Protocol error"));
102-
errorToStatus.put(ErrorCode.INVALID_STREAM,
103-
Status.INTERNAL.withDescription("Invalid stream"));
104-
errorToStatus.put(ErrorCode.UNSUPPORTED_VERSION,
105-
Status.INTERNAL.withDescription("Unsupported version"));
106-
errorToStatus.put(ErrorCode.STREAM_IN_USE,
107-
Status.INTERNAL.withDescription("Stream in use"));
108-
errorToStatus.put(ErrorCode.STREAM_ALREADY_CLOSED,
109-
Status.INTERNAL.withDescription("Stream already closed"));
110103
errorToStatus.put(ErrorCode.INTERNAL_ERROR,
111104
Status.INTERNAL.withDescription("Internal error"));
112105
errorToStatus.put(ErrorCode.FLOW_CONTROL_ERROR,
@@ -116,12 +109,17 @@ class OkHttpClientTransport implements ClientTransport {
116109
errorToStatus.put(ErrorCode.FRAME_TOO_LARGE,
117110
Status.INTERNAL.withDescription("Frame too large"));
118111
errorToStatus.put(ErrorCode.REFUSED_STREAM,
119-
Status.INTERNAL.withDescription("Refused stream"));
120-
errorToStatus.put(ErrorCode.CANCEL, Status.CANCELLED.withDescription("Cancelled"));
112+
Status.UNAVAILABLE.withDescription("Refused stream"));
113+
errorToStatus.put(ErrorCode.CANCEL,
114+
Status.CANCELLED.withDescription("Cancelled"));
121115
errorToStatus.put(ErrorCode.COMPRESSION_ERROR,
122116
Status.INTERNAL.withDescription("Compression error"));
123-
errorToStatus.put(ErrorCode.INVALID_CREDENTIALS,
124-
Status.PERMISSION_DENIED.withDescription("Invalid credentials"));
117+
errorToStatus.put(ErrorCode.CONNECT_ERROR,
118+
Status.INTERNAL.withDescription("Connect error"));
119+
errorToStatus.put(ErrorCode.ENHANCE_YOUR_CALM,
120+
Status.RESOURCE_EXHAUSTED.withDescription("Enhance your calm"));
121+
errorToStatus.put(ErrorCode.INADEQUATE_SECURITY,
122+
Status.PERMISSION_DENIED.withDescription("Inadequate security"));
125123
ERROR_CODE_TO_STATUS = Collections.unmodifiableMap(errorToStatus);
126124
}
127125

0 commit comments

Comments
 (0)