Skip to content

Commit 0cb4c43

Browse files
dmavrichevwing328
andauthored
[BUG][JAVA] Fix error handling in okhttp-gson async api client (#7089)
* Fix error handling in okhttp-gson async api client * update samples Co-authored-by: William Cheng <[email protected]>
1 parent b8e87bb commit 0cb4c43

File tree

3 files changed

+9
-0
lines changed
  • modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson
  • samples/client/petstore/java
    • okhttp-gson/src/main/java/org/openapitools/client
    • okhttp-gson-parcelableModel/src/main/java/org/openapitools/client

3 files changed

+9
-0
lines changed

modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,9 @@ public class ApiClient {
10831083
} catch (ApiException e) {
10841084
callback.onFailure(e, response.code(), response.headers().toMultimap());
10851085
return;
1086+
} catch (Exception e) {
1087+
callback.onFailure(new ApiException(e), response.code(), response.headers().toMultimap());
1088+
return;
10861089
}
10871090
callback.onSuccess(result, response.code(), response.headers().toMultimap());
10881091
}

samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,9 @@ public void onResponse(Call call, Response response) throws IOException {
10481048
} catch (ApiException e) {
10491049
callback.onFailure(e, response.code(), response.headers().toMultimap());
10501050
return;
1051+
} catch (Exception e) {
1052+
callback.onFailure(new ApiException(e), response.code(), response.headers().toMultimap());
1053+
return;
10511054
}
10521055
callback.onSuccess(result, response.code(), response.headers().toMultimap());
10531056
}

samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,9 @@ public void onResponse(Call call, Response response) throws IOException {
10481048
} catch (ApiException e) {
10491049
callback.onFailure(e, response.code(), response.headers().toMultimap());
10501050
return;
1051+
} catch (Exception e) {
1052+
callback.onFailure(new ApiException(e), response.code(), response.headers().toMultimap());
1053+
return;
10511054
}
10521055
callback.onSuccess(result, response.code(), response.headers().toMultimap());
10531056
}

0 commit comments

Comments
 (0)