@@ -1201,7 +1201,6 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
12011201 * @param authNames The authentications to apply
12021202 * @param returnType The return type into which to deserialize the response
12031203 * @param isBodyNullable True if the body is nullable
1204- * @param errorTypes Mapping of error codes to types into which to deserialize the response
12051204 * @return The response body in type of string
12061205 * @throws ApiException API exception
12071206 */
@@ -1218,8 +1217,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
12181217 String contentType,
12191218 String[] authNames,
12201219 GenericType<T > returnType,
1221- boolean isBodyNullable,
1222- Map<String , GenericType <? >> errorTypes)
1220+ boolean isBodyNullable)
12231221 throws ApiException {
12241222
12251223 String targetURL;
@@ -1349,7 +1347,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
13491347 }
13501348 }
13511349 throw new ApiException(
1352- response.getStatus(), message, buildResponseHeaders(response), respBody, deserializeErrorEntity(errorTypes, response));
1350+ response.getStatus(), message, buildResponseHeaders(response), respBody, deserializeErrorEntity(response));
13531351 }
13541352 } finally {
13551353 try {
@@ -1361,25 +1359,18 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
13611359 }
13621360 }
13631361
1362+ private static final GenericType<ErrorResponse> ERROR_GENERIC_TYPE =
1363+ new GenericType<>(ErrorResponse.class);
1364+
13641365 /**
1365- * Deserialize the response body into an error entity based on HTTP status code.
1366- * Looks up the error type from the errorTypes map using the response status code,
1367- * or falls back to the "default" error type if no match is found.
1366+ * Deserialize the response body into an error entity.
13681367 *
1369- * @param errorTypes Map of status code strings to GenericType for deserialization
13701368 * @param response The HTTP response
1371- * @return The deserialized error entity, or null if not found or deserialization fails
1369+ * @return The deserialized error entity, or null if deserialization fails
13721370 */
1373- private ErrorResponse deserializeErrorEntity(Map<String, GenericType<?>> errorTypes, Response response) {
1374- if (errorTypes == null) {
1375- return null;
1376- }
1377- GenericType<?> errorType = errorTypes.get(String.valueOf(response.getStatus()));
1378- if (errorType == null) {
1379- errorType = errorTypes.get("0"); // "0" is the "default" response
1380- }
1371+ private ErrorResponse deserializeErrorEntity(Response response) {
13811372 try {
1382- return (ErrorResponse) deserialize(response, errorType );
1373+ return deserialize(response, ERROR_GENERIC_TYPE );
13831374 } catch (Exception e) {
13841375 return null;
13851376 }
@@ -1410,7 +1401,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
14101401 */
14111402 @Deprecated
14121403 public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType, boolean isBodyNullable) throws ApiException {
1413- return invokeAPI(null, path, method, queryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType, isBodyNullable, null );
1404+ return invokeAPI(null, path, method, queryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType, isBodyNullable);
14141405 }
14151406
14161407 /**
0 commit comments