-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix the failed java unit test related to getBlob. #40
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,9 +27,17 @@ | |
import com.sun.jersey.api.client.WebResource.Builder; | ||
|
||
public class PipelineHelpers { | ||
public static void ThrowIfError(ClientResponse r) { | ||
if (r.getStatus() >= 400) { | ||
throw new UniformInterfaceException(r); | ||
public static void ThrowIfNotSuccess(ClientResponse clientResponse) { | ||
int statusCode = clientResponse.getStatus(); | ||
|
||
if ((statusCode < 200) || (statusCode >= 300)) { | ||
throw new UniformInterfaceException(clientResponse); | ||
} | ||
} | ||
|
||
public static void ThrowIfError(ClientResponse clientResponse) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: add header doc to explain the different between error and failure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since the whole file doesn't have header doc, I would leave it for now when we have more resources to do it in a systematic and consistent fashion. |
||
if (clientResponse.getStatus() >= 400) { | ||
throw new UniformInterfaceException(clientResponse); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From grammatical point of view should this be
ThrowIfNotSucceed
orThrowIfNotSucceeded
. AlsoThrowIfFailed
would be good name candidate.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the Success is Http Status code according to HTTP standard. Only if the status is 2xx, no exception would be thrown.
http://en.wikipedia.org/wiki/List_of_HTTP_status_codes