Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2012-02-15 19:30:02 -0500
committerKevin Sawicki2012-02-16 11:19:13 -0500
commit2d56c92614468d7347f998ccbf21baeb3c783a6a (patch)
treeb45d7e5518f9ce6beaa4981a57f87ae16488776a
parentd534e2cb7b84771cb5b6c85db5276557973c90f9 (diff)
downloadegit-github-2d56c92614468d7347f998ccbf21baeb3c783a6a.tar.gz
egit-github-2d56c92614468d7347f998ccbf21baeb3c783a6a.tar.xz
egit-github-2d56c92614468d7347f998ccbf21baeb3c783a6a.zip
Guard against empty request body on errors
Creating a RequestException should only be performed if a RequestError was successfully parsed from the response body. An IOException should be created in cases where the request error was missing. Change-Id: I39abc38c1e30428399c04ce3adf1dea35a8ce2ac
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
index 82ce17d6..75c49460 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
@@ -351,7 +351,7 @@ public class GitHubClient {
public GitHubClient setBufferSize(int bufferSize) {
if (bufferSize < 1)
throw new IllegalArgumentException(
- "Buffer size must be greater than zero");
+ "Buffer size must be greater than zero"); //$NON-NLS-1$
this.bufferSize = bufferSize;
return this;
@@ -498,9 +498,15 @@ public class GitHubClient {
} catch (IOException e) {
return e;
}
- return new RequestException(error, code);
- } else
- return new IOException(status);
+ if (error != null)
+ return new RequestException(error, code);
+ }
+ String message;
+ if (status != null && status.length() > 0)
+ message = status + " (" + code + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ else
+ message = "Unknown error occurred (" + code + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return new IOException(message);
}
/**

Back to the top