Minor: CallSubject.hasHttpStatus() throws unchecked CallFailedRuntimeException
This commit is contained in:
committed by
Aleksandar Vidakovic
parent
43ef6e1983
commit
420d26a679
@@ -42,15 +42,18 @@ public final class Calls {
|
||||
* [200..300) successful
|
||||
*/
|
||||
public static <T> T ok(Call<T> call) throws CallFailedRuntimeException {
|
||||
Response<T> response;
|
||||
try {
|
||||
response = call.execute();
|
||||
} catch (IOException e) {
|
||||
throw new CallFailedRuntimeException(call, e);
|
||||
}
|
||||
Response<T> response = executeU(call);
|
||||
if (response.isSuccessful()) {
|
||||
return response.body();
|
||||
}
|
||||
throw new CallFailedRuntimeException(call, response);
|
||||
}
|
||||
|
||||
public static <T> Response<T> executeU(Call<T> call) throws CallFailedRuntimeException {
|
||||
try {
|
||||
return call.execute();
|
||||
} catch (IOException e) {
|
||||
throw new CallFailedRuntimeException(call, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public final class Parts {
|
||||
return Part.createFormData("file", file.getName(), rb);
|
||||
}
|
||||
|
||||
public static Part fromFile(String fileName, byte[] bytes) {
|
||||
public static Part fromBytes(String fileName, byte[] bytes) {
|
||||
RequestBody rb = RequestBody.create(bytes, mediaType(fileName));
|
||||
return Part.createFormData("file", fileName, rb);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user