Skip to content

Commit 4660702

Browse files
authored
Merge pull request #1529 from yue9944882/generic-api-handling-status-code
Passing actual response status code in generic api's error handler
2 parents c8a1c31 + ff80fa1 commit 4660702

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

util/src/main/java/io/kubernetes/client/util/generic/KubernetesApiResponse.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public boolean isSuccess() {
5959
*/
6060
public KubernetesApiResponse<DataType> throwsApiException() throws ApiException {
6161
return onFailure(
62-
errorStatus -> {
63-
throw new ApiException(errorStatus.toString());
62+
(code, errorStatus) -> {
63+
throw new ApiException(code, errorStatus.toString());
6464
});
6565
}
6666

@@ -74,12 +74,12 @@ public KubernetesApiResponse<DataType> throwsApiException() throws ApiException
7474
public KubernetesApiResponse<DataType> onFailure(ErrorStatusHandler errorStatusHandler)
7575
throws ApiException {
7676
if (!isSuccess()) {
77-
errorStatusHandler.handle(this.status);
77+
errorStatusHandler.handle(this.getHttpStatusCode(), this.status);
7878
}
7979
return this;
8080
}
8181

8282
public interface ErrorStatusHandler {
83-
void handle(V1Status errorStatus) throws ApiException;
83+
void handle(int code, V1Status errorStatus) throws ApiException;
8484
}
8585
}

util/src/test/java/io/kubernetes/client/util/generic/KubernetesApiResponseTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void testErrorStatusHandler() throws ApiException {
5555
podClient
5656
.delete("default", "foo")
5757
.onFailure(
58-
errStatus -> {
58+
(code, errStatus) -> {
5959
catched.set(true);
6060
})
6161
.getObject());

0 commit comments

Comments
 (0)