Skip to content

Commit ef2cbd5

Browse files
authored
Merge pull request #7 from valfirst/clean-up-remove-immediate-rethrows-of-caught-exceptions
Clean up: remove immediate rethrows of caught exceptions
2 parents b22e330 + 9c3f319 commit ef2cbd5

File tree

1 file changed

+11
-35
lines changed

1 file changed

+11
-35
lines changed

src/main/java/com/browserstack/client/BrowserStackClient.java

+11-35
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,7 @@ public List<Build> getBuilds(final BuildStatus status, final int limit, final St
307307
httpRequest.queryString(Constants.Filter.BUILD_NAME, buildName);
308308
}
309309

310-
final List<BuildNode> buildNodes;
311-
try {
312-
buildNodes = Arrays.asList(httpRequest.asObject(BuildNode[].class));
313-
} catch (BrowserStackException e) {
314-
throw e;
315-
}
310+
final List<BuildNode> buildNodes = Arrays.asList(httpRequest.asObject(BuildNode[].class));
316311

317312
final List<Build> builds = new ArrayList<Build>();
318313
for (BuildNode buildNode : buildNodes) {
@@ -405,8 +400,6 @@ public Build getBuild(final String buildId) throws BuildNotFound, BrowserStackEx
405400
return buildNode.getBuild().setClient(this);
406401
} catch (BrowserStackObjectNotFound e) {
407402
throw new BuildNotFound("Build not found: " + buildId);
408-
} catch (BrowserStackException e) {
409-
throw e;
410403
}
411404
}
412405

@@ -419,15 +412,11 @@ public Build getBuild(final String buildId) throws BuildNotFound, BrowserStackEx
419412
* @throws BrowserStackException
420413
*/
421414
public Build getBuildByName(@Nonnull final String buildName) throws BuildNotFound, BrowserStackException {
422-
try {
423-
final List<Build> build = getBuilds(null, 1, buildName);
424-
if (build.size() == 1) {
425-
return build.get(0);
426-
}
427-
throw new BuildNotFound("Build not found by name: " + buildName);
428-
} catch (BrowserStackException e) {
429-
throw e;
415+
final List<Build> build = getBuilds(null, 1, buildName);
416+
if (build.size() == 1) {
417+
return build.get(0);
430418
}
419+
throw new BuildNotFound("Build not found by name: " + buildName);
431420
}
432421

433422
/**
@@ -438,15 +427,11 @@ public Build getBuildByName(@Nonnull final String buildName) throws BuildNotFoun
438427
* @throws BrowserStackException
439428
*/
440429
public boolean deleteBuild(final String buildId) throws BrowserStackException {
441-
try {
442-
ObjectNode result = newRequest(BrowserStackClient.Method.DELETE, "/builds/{buildId}.json")
443-
.routeParam("buildId", buildId).asJsonObject();
430+
ObjectNode result = newRequest(Method.DELETE, "/builds/{buildId}.json")
431+
.routeParam("buildId", buildId).asJsonObject();
444432

445-
String status = (result != null) ? result.path("status").asText() : null;
446-
return (status != null && status.equals("ok"));
447-
} catch (BrowserStackException e) {
448-
throw e;
449-
}
433+
String status = (result != null) ? result.path("status").asText() : null;
434+
return (status != null && status.equals("ok"));
450435
}
451436

452437
/**
@@ -497,13 +482,8 @@ public List<Session> getSessions(final String buildId, final BuildStatus status,
497482
}
498483

499484
private List<SessionNode> getSessionNodes(String buildId, BuildStatus status, int totalLimit, int offset) throws BrowserStackException {
500-
BrowserStackRequest httpRequest;
501-
try {
502-
httpRequest =
503-
newRequest(Method.GET, "/builds/{buildId}/sessions.json").routeParam("buildId", buildId);
504-
} catch (BrowserStackException e) {
505-
throw e;
506-
}
485+
BrowserStackRequest httpRequest = newRequest(Method.GET, "/builds/{buildId}/sessions.json").routeParam(
486+
"buildId", buildId);
507487

508488
httpRequest.queryString(Constants.Filter.LIMIT, totalLimit);
509489
httpRequest.queryString(Constants.Filter.OFFSET, offset);
@@ -517,8 +497,6 @@ private List<SessionNode> getSessionNodes(String buildId, BuildStatus status, in
517497
sessionNodes = Arrays.asList(httpRequest.asObject(SessionNode[].class));
518498
} catch (BrowserStackObjectNotFound e) {
519499
throw new BuildNotFound("Build not found: " + buildId);
520-
} catch (BrowserStackException e) {
521-
throw e;
522500
}
523501
return sessionNodes;
524502
}
@@ -583,8 +561,6 @@ public Session getSession(String sessionId) throws SessionNotFound, BrowserStack
583561
return sessionNode.getSession().setClient(this);
584562
} catch (BrowserStackObjectNotFound e) {
585563
throw new SessionNotFound("Session not found: " + sessionId);
586-
} catch (BrowserStackException e) {
587-
throw e;
588564
}
589565
}
590566

0 commit comments

Comments
 (0)