Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 2d56c92614468d7347f998ccbf21baeb3c783a6a 1 parent d534e2c
@kevinsawicki kevinsawicki authored
View
14 org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
@@ -351,7 +351,7 @@ public GitHubClient setOAuth2Token(String token) {
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 @@ protected IOException createException(InputStream response, int code,
} 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);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.