Skip to content
This repository was archived by the owner on May 14, 2026. It is now read-only.

Commit efbe7ba

Browse files
committed
docs: add javadoc for private methods
1 parent f38a66d commit efbe7ba

1 file changed

Lines changed: 67 additions & 1 deletion

File tree

gax-java/gax/src/main/java/com/google/api/gax/tracing/ErrorTypeUtil.java

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ public static String extractErrorType(@Nullable Throwable error) {
132132
return ErrorType.INTERNAL.toString();
133133
}
134134

135+
/**
136+
* Extracts the error type from an ApiException. This method prioritizes the ErrorInfo reason,
137+
* then the transport-specific status code (HTTP or gRPC).
138+
*
139+
* @param apiException The ApiException to extract the error type from.
140+
* @return A string representing the error type, or null if no specific type can be determined.
141+
*/
135142
@Nullable
136143
private static String extractFromApiException(ApiException apiException) {
137144
// 1. Check for ErrorInfo.reason
@@ -154,6 +161,13 @@ private static String extractFromApiException(ApiException apiException) {
154161
return null;
155162
}
156163

164+
/**
165+
* Determines the client-side error type based on the provided Throwable. This method checks for
166+
* various network and client-specific exceptions.
167+
*
168+
* @param error The Throwable to analyze.
169+
* @return A string representing the client-side error type, or null if not matched.
170+
*/
157171
@Nullable
158172
private static String getClientSideError(Throwable error) {
159173
if (isClientTimeout(error)) {
@@ -171,7 +185,8 @@ private static String getClientSideError(Throwable error) {
171185
if (isClientRedirectError(error)) {
172186
return ErrorType.CLIENT_REDIRECT_ERROR.toString();
173187
}
174-
if (error instanceof IllegalArgumentException) { // This covers CLIENT_REQUEST_ERROR
188+
// This covers CLIENT_REQUEST_ERROR for general illegal arguments in client requests.
189+
if (error instanceof IllegalArgumentException) {
175190
return ErrorType.CLIENT_REQUEST_ERROR.toString();
176191
}
177192
if (isRequestBodyError(error)) {
@@ -183,35 +198,86 @@ private static String getClientSideError(Throwable error) {
183198
return null;
184199
}
185200

201+
/**
202+
* Checks if the given Throwable represents a client-side timeout error. This includes socket
203+
* timeouts and GAX-specific watchdog timeouts.
204+
*
205+
* @param e The Throwable to check.
206+
* @return true if the error is a client timeout, false otherwise.
207+
*/
186208
private static boolean isClientTimeout(Throwable e) {
187209
return e instanceof SocketTimeoutException || e instanceof WatchdogTimeoutException;
188210
}
189211

212+
/**
213+
* Checks if the given Throwable represents a client-side connection error. This includes issues
214+
* with establishing connections, unknown hosts, SSL handshakes, and unresolved addresses.
215+
*
216+
* @param e The Throwable to check.
217+
* @return true if the error is a client connection error, false otherwise.
218+
*/
190219
private static boolean isClientConnectionError(Throwable e) {
191220
return e instanceof ConnectException
192221
|| e instanceof UnknownHostException
193222
|| e instanceof SSLHandshakeException
194223
|| e instanceof UnresolvedAddressException;
195224
}
196225

226+
/**
227+
* Checks if the given Throwable represents a client-side response decoding error. This is
228+
* identified by exceptions related to JSON or Gson parsing, either directly or as a cause.
229+
*
230+
* @param e The Throwable to check.
231+
* @return true if the error is a client response decode error, false otherwise.
232+
*/
197233
private static boolean isClientResponseDecodeError(Throwable e) {
198234
return e.getClass().getName().contains("Json")
199235
|| e.getClass().getName().contains("Gson")
200236
|| (e.getCause() != null && e.getCause().getClass().getName().contains("Gson"));
201237
}
202238

239+
/**
240+
* Checks if the given Throwable represents a client-side redirect error. This is identified by
241+
* the presence of "redirect" in the exception message.
242+
*
243+
* @param e The Throwable to check.
244+
* @return true if the error is a client redirect error, false otherwise.
245+
*/
203246
private static boolean isClientRedirectError(Throwable e) {
204247
return e.getMessage() != null && e.getMessage().contains("redirect");
205248
}
206249

250+
/**
251+
* Checks if the given Throwable represents a client-side authentication error. This is identified
252+
* by exceptions related to the auth library.
253+
*
254+
* @param e The Throwable to check.
255+
* @return true if the error is a client authentication error, false otherwise.
256+
*/
207257
private static boolean isClientAuthenticationError(Throwable e) {
208258
return e.getClass().getName().contains("GoogleAuthException");
209259
}
210260

261+
/**
262+
* Checks if the given Throwable represents a client-side request body error. This is specifically
263+
* mapped to RestSerializationException from httpjson, which indicates issues during the
264+
* serialization of the request body for REST calls.
265+
*
266+
* @param e The Throwable to check.
267+
* @return true if the error is a client request body error, false otherwise.
268+
*/
211269
private static boolean isRequestBodyError(Throwable e) {
212270
return e.getClass().getName().contains("RestSerializationException");
213271
}
214272

273+
/**
274+
* Checks if the given Throwable represents an unknown client-side error. This is a general
275+
* fallback for exceptions whose class name contains "unknown", indicating an unclassified
276+
* client-side issue.
277+
*
278+
* @param e The Throwable to check.
279+
* @return true if the error is an unknown client error, false otherwise.
280+
*/
215281
private static boolean isClientUnknownError(Throwable e) {
216282
return e.getClass().getName().toLowerCase().contains("unknown");
217283
}

0 commit comments

Comments
 (0)