Commit 4aede591 authored by Greg Messner's avatar Greg Messner
Browse files

Modified handle() to only return the exception not throw it.

parent 577088d3
...@@ -225,7 +225,8 @@ public abstract class AbstractApi { ...@@ -225,7 +225,8 @@ public abstract class AbstractApi {
} }
/** /**
* Validates response. * Validates response the response from the server against the expected HTTP status and
* the returned secret token, if either is not correct will throw a GitLabApiException.
* *
* @param response response * @param response response
* @param expected expected respone status * @param expected expected respone status
...@@ -233,6 +234,7 @@ public abstract class AbstractApi { ...@@ -233,6 +234,7 @@ public abstract class AbstractApi {
* @throws GitLabApiException if HTTP status is not as expected, or the secret token doesn't match * @throws GitLabApiException if HTTP status is not as expected, or the secret token doesn't match
*/ */
protected Response validate(Response response, Response.Status expected) throws GitLabApiException { protected Response validate(Response response, Response.Status expected) throws GitLabApiException {
if (response.getStatus() != expected.getStatusCode()) { if (response.getStatus() != expected.getStatusCode()) {
throw new GitLabApiException(response); throw new GitLabApiException(response);
} }
...@@ -245,17 +247,16 @@ public abstract class AbstractApi { ...@@ -245,17 +247,16 @@ public abstract class AbstractApi {
} }
/** /**
* Wraps exception if needed * Wraps an exception in a GitLabApiException if needed.
* *
* @param thrown the exception that should be wrapped * @param thrown the exception that should be wrapped
* @throws GitLabApiException containing the cause or GitLab API specific message
*/ */
protected GitLabApiException handle(Exception thrown) throws GitLabApiException { protected GitLabApiException handle(Exception thrown) {
if (thrown instanceof GitLabApiException) { if (thrown instanceof GitLabApiException) {
throw (GitLabApiException) thrown; return ((GitLabApiException) thrown);
} }
throw new GitLabApiException(thrown); return (new GitLabApiException(thrown));
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment