1+ /*
2+ * Copyright 2025 The gRPC Authors
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ package io .grpc .internal ;
18+
19+ import javax .annotation .concurrent .Immutable ;
20+
21+ /**
22+ * Represents a fixed, static reason for disconnection.
23+ */
24+ @ Immutable
25+ public enum SimpleDisconnectError implements DisconnectError {
26+ /**
27+ * The subchannel was shut down for various reasons like parent channel shutdown,
28+ * idleness, or load balancing policy changes.
29+ */
30+ SUBCHANNEL_SHUTDOWN ("subchannel shutdown" ),
31+
32+ /**
33+ * Connection was reset (e.g., ECONNRESET, WSAECONNERESET).
34+ */
35+ CONNECTION_RESET ("connection reset" ),
36+
37+ /**
38+ * Connection timed out (e.g., ETIMEDOUT, WSAETIMEDOUT), including closures
39+ * from gRPC keepalives.
40+ */
41+ CONNECTION_TIMED_OUT ("connection timed out" ),
42+
43+ /**
44+ * Connection was aborted (e.g., ECONNABORTED, WSAECONNABORTED).
45+ */
46+ CONNECTION_ABORTED ("connection aborted" ),
47+
48+ /**
49+ * Any socket error not covered by other specific disconnect errors.
50+ */
51+ SOCKET_ERROR ("socket error" ),
52+
53+ /**
54+ * A catch-all for any other unclassified reason.
55+ */
56+ UNKNOWN ("unknown" );
57+
58+ private final String errorTag ;
59+
60+ SimpleDisconnectError (String errorTag ) {
61+ this .errorTag = errorTag ;
62+ }
63+
64+ @ Override
65+ public String toErrorString () {
66+ return this .errorTag ;
67+ }
68+ }
0 commit comments