diff options
| author | Kevin Sawicki | 2011-04-19 21:17:04 +0000 |
|---|---|---|
| committer | Kevin Sawicki | 2011-04-19 21:17:04 +0000 |
| commit | 71d3ea86a0e34b3da7ee3e0672d4bbc21b16f742 (patch) | |
| tree | f1d502f1d2b9fa6742a5285bf178b489c3cc9abd | |
| parent | 5ee3f2cca3501446b616904d484e68d6c6d74d1b (diff) | |
| download | egit-github-71d3ea86a0e34b3da7ee3e0672d4bbc21b16f742.tar.gz egit-github-71d3ea86a0e34b3da7ee3e0672d4bbc21b16f742.tar.xz egit-github-71d3ea86a0e34b3da7ee3e0672d4bbc21b16f742.zip | |
Add response status value to request exception
Change-Id: Ida4cb329426e51a2961123386de0d3faea31edfc
Signed-off-by: Kevin Sawicki <kevin@github.com>
| -rw-r--r-- | org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java | 30 | ||||
| -rw-r--r-- | org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/RequestException.java | 21 |
2 files changed, 32 insertions, 19 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java index ffbe25b1..594f3739 100644 --- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java +++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubClient.java @@ -69,7 +69,7 @@ public class GitHubClient { /** * Create client for configuration - * + * * @param configuration */ public GitHubClient(HostConfiguration configuration) { @@ -78,7 +78,7 @@ public class GitHubClient { /** * Create standard post method - * + * * @param uri * @return post */ @@ -102,7 +102,7 @@ public class GitHubClient { /** * Set method defaults - * + * * @param method * @return method */ @@ -117,7 +117,7 @@ public class GitHubClient { /** * Create get method - * + * * @param uri * @return get method */ @@ -130,7 +130,7 @@ public class GitHubClient { /** * Set credentials - * + * * @param user * @param password */ @@ -144,7 +144,7 @@ public class GitHubClient { /** * Parse json to specified type - * + * * @param <V> * @param method * @param type @@ -162,7 +162,7 @@ public class GitHubClient { /** * Get name value pairs for data map. - * + * * @param data * @return name value pair array */ @@ -178,7 +178,7 @@ public class GitHubClient { /** * Get response from uri and bind to specified type - * + * * @param <V> * @param uri * @param type @@ -213,7 +213,7 @@ public class GitHubClient { case 404: case 500: RequestError error = parseJson(method, RequestError.class); - throw new RequestException(error); + throw new RequestException(error, status); default: throw new IOException(method.getStatusText()); } @@ -224,7 +224,7 @@ public class GitHubClient { /** * Get response from uri and bind to specified type - * + * * @param <V> * @param uri * @param params @@ -247,7 +247,7 @@ public class GitHubClient { case 404: case 500: RequestError error = parseJson(method, RequestError.class); - throw new RequestException(error); + throw new RequestException(error, status); default: throw new IOException(method.getStatusText()); } @@ -268,8 +268,8 @@ public class GitHubClient { * @return resource * @throws IOException */ - protected <V> V sendJson(EntityEnclosingMethod method, - Object params, Type type) throws IOException { + protected <V> V sendJson(EntityEnclosingMethod method, Object params, + Type type) throws IOException { if (params != null) { StringBuilder payload = new StringBuilder(); this.gson.toJson(params, payload); @@ -291,7 +291,7 @@ public class GitHubClient { case 404: case 500: RequestError error = parseJson(method, RequestError.class); - throw new RequestException(error); + throw new RequestException(error, status); default: throw new IOException(method.getStatusText()); } @@ -303,7 +303,7 @@ public class GitHubClient { /** * Post data to uri - * + * * @param <V> * @param uri * @param params diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/RequestException.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/RequestException.java index add41565..e36122e3 100644 --- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/RequestException.java +++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/RequestException.java @@ -14,7 +14,7 @@ import java.io.IOException; /** * Request exception class that wraps an {@link RequestError} object. - * + * * @author Kevin Sawicki (kevin@github.com) */ public class RequestException extends IOException { @@ -25,23 +25,36 @@ public class RequestException extends IOException { private static final long serialVersionUID = 1197051396535284852L; private RequestError error; + private int status; /** * Create request exception - * + * * @param error + * @param status */ - public RequestException(RequestError error) { + public RequestException(RequestError error, int status) { super(error.getMessage()); + this.error = error; + this.status = status; } /** * Get error - * + * * @return error */ public RequestError getError() { return this.error; } + /** + * Get status + * + * @return status + */ + public int getStatus() { + return this.status; + } + } |
