Commit a6cb160c authored by Greg Messner's avatar Greg Messner
Browse files

Changed handling of unexpected HTTP status.

parent 206dba0b
...@@ -34,18 +34,18 @@ public abstract class AbstractApi { ...@@ -34,18 +34,18 @@ public abstract class AbstractApi {
protected ClientResponse get (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, Object ... pathArgs) protected ClientResponse get (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, Object ... pathArgs)
throws GitLabApiException { throws GitLabApiException {
try { ClientResponse response = null;
try {
ClientResponse response = getApiClient().get(queryParams, pathArgs); response = getApiClient().get(queryParams, pathArgs);
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
} catch (Exception e) { } catch (Exception e) {
throw (new GitLabApiException(e)); throw (new GitLabApiException(e));
} }
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
} }
...@@ -62,18 +62,18 @@ public abstract class AbstractApi { ...@@ -62,18 +62,18 @@ public abstract class AbstractApi {
protected ClientResponse get (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, URL url) protected ClientResponse get (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, URL url)
throws GitLabApiException { throws GitLabApiException {
try { ClientResponse response = null;
try {
ClientResponse response = getApiClient().get(queryParams, url); response = getApiClient().get(queryParams, url);
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
} catch (Exception e) { } catch (Exception e) {
throw (new GitLabApiException(e)); throw (new GitLabApiException(e));
} }
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
} }
...@@ -89,18 +89,18 @@ public abstract class AbstractApi { ...@@ -89,18 +89,18 @@ public abstract class AbstractApi {
*/ */
protected ClientResponse post (ClientResponse.Status expectedStatus, Form formData, Object ... pathArgs) throws GitLabApiException { protected ClientResponse post (ClientResponse.Status expectedStatus, Form formData, Object ... pathArgs) throws GitLabApiException {
try { ClientResponse response = null;
try {
ClientResponse response = getApiClient().post(formData, pathArgs); response = getApiClient().post(formData, pathArgs);
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
} catch (Exception e) { } catch (Exception e) {
throw (new GitLabApiException(e)); throw (new GitLabApiException(e));
} }
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
} }
...@@ -116,18 +116,18 @@ public abstract class AbstractApi { ...@@ -116,18 +116,18 @@ public abstract class AbstractApi {
*/ */
protected ClientResponse post (ClientResponse.Status expectedStatus, Form formData, URL url) throws GitLabApiException { protected ClientResponse post (ClientResponse.Status expectedStatus, Form formData, URL url) throws GitLabApiException {
try { ClientResponse response = null;
try {
ClientResponse response = getApiClient().post(formData, url); response = getApiClient().post(formData, url);
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
} catch (Exception e) { } catch (Exception e) {
throw (new GitLabApiException(e)); throw (new GitLabApiException(e));
} }
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
} }
...@@ -144,18 +144,18 @@ public abstract class AbstractApi { ...@@ -144,18 +144,18 @@ public abstract class AbstractApi {
*/ */
protected ClientResponse put (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, Object ... pathArgs) throws GitLabApiException { protected ClientResponse put (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, Object ... pathArgs) throws GitLabApiException {
try { ClientResponse response = null;
try {
ClientResponse response = getApiClient().put(queryParams, pathArgs); response = getApiClient().put(queryParams, pathArgs);
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
} catch (Exception e) { } catch (Exception e) {
throw (new GitLabApiException(e)); throw (new GitLabApiException(e));
} }
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
} }
...@@ -171,18 +171,18 @@ public abstract class AbstractApi { ...@@ -171,18 +171,18 @@ public abstract class AbstractApi {
*/ */
protected ClientResponse put (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, URL url) throws GitLabApiException { protected ClientResponse put (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, URL url) throws GitLabApiException {
try { ClientResponse response = null;
try {
ClientResponse response = getApiClient().put(queryParams, url); response = getApiClient().put(queryParams, url);
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
} catch (Exception e) { } catch (Exception e) {
throw (new GitLabApiException(e)); throw (new GitLabApiException(e));
} }
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
} }
...@@ -199,18 +199,18 @@ public abstract class AbstractApi { ...@@ -199,18 +199,18 @@ public abstract class AbstractApi {
protected ClientResponse delete (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, Object ... pathArgs) protected ClientResponse delete (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, Object ... pathArgs)
throws GitLabApiException { throws GitLabApiException {
try { ClientResponse response = null;
try {
ClientResponse response = getApiClient().delete(queryParams, pathArgs); response = getApiClient().delete(queryParams, pathArgs);
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
} catch (Exception e) { } catch (Exception e) {
throw (new GitLabApiException(e)); throw (new GitLabApiException(e));
} }
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
} }
...@@ -226,18 +226,18 @@ public abstract class AbstractApi { ...@@ -226,18 +226,18 @@ public abstract class AbstractApi {
*/ */
protected ClientResponse delete (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, URL url) throws GitLabApiException { protected ClientResponse delete (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, URL url) throws GitLabApiException {
try { ClientResponse response = null;
try {
ClientResponse response = getApiClient().delete(queryParams, url); response = getApiClient().delete(queryParams, url);
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
} catch (Exception e) { } catch (Exception e) {
throw (new GitLabApiException(e)); throw (new GitLabApiException(e));
} }
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
} }
......
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