Я использую функцию приостановки для вызова API, как показано в коде ниже. Как я могу получить конечную точку URL-адреса и метод GET/POST при возникновении исключения?
suspend fun safeCallApi(
api: suspend () -> Response
): Result {
return try {
val response = api()
if (response.isSuccessful) {
val body = response.body()
if (body != null) {
Result.success(body)
} else {
Result.failure(BodyNullException())
}
} else {
Result.failure(ServerException())
}
} catch (e: Exception) {
// I want to obtain the information about the URL endpoint and the GET/POST method there.
Result.failure(UnknownException(e))
}
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... ion-occurs