Skip to content

Commit

Permalink
Removed use of general Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Kadaner committed Feb 28, 2016
1 parent e5c9156 commit 07e7857
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/java/com/checkmarx/jenkins/web/client/RestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.Closeable;
import java.util.Map;

import javax.ws.rs.WebApplicationException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
Expand All @@ -11,7 +12,6 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.NewCookie;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;

import com.checkmarx.jenkins.web.model.AnalyzeRequest;
import com.checkmarx.jenkins.web.model.AuthenticationRequest;
Expand Down Expand Up @@ -40,7 +40,7 @@ public RestClient(String serverUri, AuthenticationRequest authenticationRequest)
root = client.target(serverUri).path(ROOT_PATH);
}

public void analyzeOpenSources(AnalyzeRequest request) throws Exception {
public void analyzeOpenSources(AnalyzeRequest request) {
Cookie cookie = authenticate();
Response response = root.path(ANALYZE_PATH)
.request()
Expand All @@ -50,7 +50,7 @@ public void analyzeOpenSources(AnalyzeRequest request) throws Exception {
validateResponse(response);
}

public GetOpenSourceSummaryResponse getOpenSourceSummary(GetOpenSourceSummaryRequest request) throws Exception {
public GetOpenSourceSummaryResponse getOpenSourceSummary(GetOpenSourceSummaryRequest request) {
Cookie cookie = authenticate();
return root.path(ANALYZE_SUMMARY_PATH)
.resolveTemplate("projectId", request.getProjectId())
Expand All @@ -59,7 +59,7 @@ public GetOpenSourceSummaryResponse getOpenSourceSummary(GetOpenSourceSummaryReq
.get(GetOpenSourceSummaryResponse.class);
}

private Cookie authenticate() throws Exception {
private Cookie authenticate() {
Response response = root.path(AUTHENTICATION_PATH)
.request()
.post(Entity.entity(authenticationRequest, MediaType.APPLICATION_JSON));
Expand All @@ -72,10 +72,10 @@ private Cookie authenticate() throws Exception {
return cookieEntry.getValue();
}

private void validateResponse(Response response) throws Exception {
if (response.getStatus() >= Status.BAD_REQUEST.getStatusCode()) {
private void validateResponse(Response response) {
if (response.getStatus() >= 400) {
CxException cxException = response.readEntity(CxException.class);
throw new Exception(cxException.getMessage() + "\n" + cxException.getMessageDetails());
throw new WebApplicationException(cxException.getMessage() + "\n" + cxException.getMessageDetails(), response);
}
}

Expand Down

0 comments on commit 07e7857

Please sign in to comment.