diff --git a/src/main/java/com/openshift/internal/restclient/capability/resources/DeployCapability.java b/src/main/java/com/openshift/internal/restclient/capability/resources/DeployCapability.java index 3294e2a1..068d53c6 100644 --- a/src/main/java/com/openshift/internal/restclient/capability/resources/DeployCapability.java +++ b/src/main/java/com/openshift/internal/restclient/capability/resources/DeployCapability.java @@ -62,8 +62,8 @@ public void deploy() { LOG.debug("Skipping deployment because deployment status %s for %s is not in %s", new Object [] {status, deploymentName, COMPLETED_STATES}); return; } - }catch(OpenShiftException e) { - if(e.getStatus() == null || e.getStatus().getCode() != IHttpConstants.STATUS_NOT_FOUND) { + } catch(OpenShiftException e) { + if (e.getStatus() == null || e.getStatus().getCode() != IHttpConstants.STATUS_NOT_FOUND) { //swallow exception like cli throw e; } @@ -82,7 +82,7 @@ private String getLatestDeploymentName() { } private String getStatusFor(IReplicationController rc) { - if(rc.isAnnotatedWith(IReplicationController.DEPLOYMENT_PHASE)) { + if (rc.isAnnotatedWith(IReplicationController.DEPLOYMENT_PHASE)) { return rc.getAnnotation(IReplicationController.DEPLOYMENT_PHASE); } return ""; diff --git a/src/main/java/com/openshift/internal/restclient/okhttp/ResponseCodeInterceptor.java b/src/main/java/com/openshift/internal/restclient/okhttp/ResponseCodeInterceptor.java index 6b600863..69930fda 100644 --- a/src/main/java/com/openshift/internal/restclient/okhttp/ResponseCodeInterceptor.java +++ b/src/main/java/com/openshift/internal/restclient/okhttp/ResponseCodeInterceptor.java @@ -109,7 +109,7 @@ public static OpenShiftException createOpenShiftException(IClient client, Respon AuthorizationDetails details = new AuthorizationDetails(response.headers(), link); return new com.openshift.restclient.authorization.UnauthorizedException(details, status); case IHttpConstants.STATUS_NOT_FOUND: - return new NotFoundException(status == null ? "Not Found" : status.getMessage()); + return new NotFoundException(e, status, status == null ? "Not Found" : status.getMessage()); default: return new OpenShiftException(e, status, "Exception trying to %s %s response code: %s", response.request().method(), response.request().url().toString(), responseCode); } diff --git a/src/main/java/com/openshift/restclient/NotFoundException.java b/src/main/java/com/openshift/restclient/NotFoundException.java index 63fd3a22..9f539707 100644 --- a/src/main/java/com/openshift/restclient/NotFoundException.java +++ b/src/main/java/com/openshift/restclient/NotFoundException.java @@ -10,6 +10,8 @@ ******************************************************************************/ package com.openshift.restclient; +import com.openshift.restclient.model.IStatus; + /** * @author jeff.cantrill */ @@ -28,4 +30,8 @@ public NotFoundException(String message) { public NotFoundException(Throwable cause) { super(cause, ""); } + + public NotFoundException(Throwable cause, IStatus status, String message, Object... arguments) { + super(cause, status, message, arguments); + } } diff --git a/src/test/java/com/openshift/internal/restclient/capability/resources/DeployCapabilityTest.java b/src/test/java/com/openshift/internal/restclient/capability/resources/DeployCapabilityTest.java index 129d1049..378b564b 100644 --- a/src/test/java/com/openshift/internal/restclient/capability/resources/DeployCapabilityTest.java +++ b/src/test/java/com/openshift/internal/restclient/capability/resources/DeployCapabilityTest.java @@ -21,6 +21,7 @@ import org.mockito.runners.MockitoJUnitRunner; import com.openshift.restclient.IClient; +import com.openshift.restclient.NotFoundException; import com.openshift.restclient.OpenShiftException; import com.openshift.restclient.capability.resources.IDeployCapability; import com.openshift.restclient.http.IHttpConstants; @@ -121,7 +122,7 @@ private void givenTheDeploymentIsRetrieved() { private void givenTheLatestDeploymentIsNotFound() { IStatus status = mock(IStatus.class); when(status.getCode()).thenReturn(IHttpConstants.STATUS_NOT_FOUND); - OpenShiftException e = new OpenShiftException(new RuntimeException(), status, ""); + NotFoundException e = new NotFoundException(null, status, "Not Found"); when(client.get(anyString(),anyString(),anyString())).thenThrow(e); } }