Minor: CallSubject.hasHttpStatus() throws unchecked CallFailedRuntimeException

This commit is contained in:
Michael Vorburger
2020-10-24 23:36:03 +02:00
committed by Aleksandar Vidakovic
parent 43ef6e1983
commit 420d26a679
4 changed files with 16 additions and 13 deletions
@@ -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);
}