Tests pass but logging is still required

This commit is contained in:
2024-07-19 17:21:27 +01:00
parent 982b4e8d5d
commit 5bb6ccb789
20 changed files with 468 additions and 104 deletions

View File

@@ -4,6 +4,7 @@ import java.io.IOException
abstract class NetworkTests {
// Call retrofit API and unwrap response or throw exception
fun <T : Any> responseUnwrap(
call: suspend () -> Response<T>
): T {
@@ -12,9 +13,11 @@ abstract class NetworkTests {
if (response.isSuccessful) {
return response.body()!!
} else {
val error = response.errorBody()?.string()
throw IOException(error ?: "Unable to handle end point")
val error = StringBuilder().append(response.code()).append(" : ")
.append(response.errorBody()?.string() ?: "Unable to handle end point").toString()
print(response.raw())
throw IOException(error)
}
}
}