mirror of
https://github.com/hmalik144/api-testing-automation-framework.git
synced 2025-12-10 02:55:21 +00:00
Tests pass but logging is still required
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user