Skip to content

Commit

Permalink
Improve converter error handling #389
Browse files Browse the repository at this point in the history
  • Loading branch information
Foso committed Oct 8, 2023
1 parent c25a71c commit 241b770
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ public class CallConverterFactory : Converter.Factory {
}

is KtorfitResult.Failed -> {
result.throwable.let {
callBack.onError(it)
}
callBack.onError(result.throwable)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class Response<T> private constructor(
}

/** Create an error response from `rawResponse` with `body` as the error body. */
public fun <T> error(body: Any?, rawResponse: HttpResponse): Response<T?> {
public fun <T> error(body: Any, rawResponse: HttpResponse): Response<T?> {
require(!rawResponse.status.isSuccess()) { "rawResponse should not be successful response" }
return Response(rawResponse, null, body)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ internal class DefaultSuspendResponseConverterFactory : Converter.Factory {
}

is KtorfitResult.Success -> {
val response = result.response
response.call.body(typeData.typeInfo)
result.response.call.body(typeData.typeInfo)
}
}
}
Expand Down

0 comments on commit 241b770

Please sign in to comment.