Skip to content

Commit c032f5c

Browse files
authored
Merge pull request #12 from haroldadmin/merge-dev
Merge development features into master
2 parents 9fff6bc + fc4d470 commit c032f5c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/main/kotlin/com/haroldadmin/cnradapter/ErrorExtraction.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import java.io.IOException
77

88
internal const val UNKNOWN_ERROR_RESPONSE_CODE = 520
99

10-
internal fun <S : Any, E : Any> HttpException.extractFromHttpException(
11-
errorConverter: Converter<ResponseBody, E>
12-
): NetworkResponse<S, E> {
10+
internal fun <E : Any> HttpException.extractFromHttpException(
11+
errorConverter: Converter<ResponseBody, E>
12+
): NetworkResponse.ServerError<E> {
1313
val error = response()?.errorBody()
1414
val responseCode = response()?.code() ?: UNKNOWN_ERROR_RESPONSE_CODE
1515
val headers = response()?.headers()
@@ -28,11 +28,11 @@ internal fun <S : Any, E : Any> HttpException.extractFromHttpException(
2828
}
2929

3030
internal fun <S : Any, E : Any> Throwable.extractNetworkResponse(
31-
errorConverter: Converter<ResponseBody, E>
31+
errorConverter: Converter<ResponseBody, E>
3232
): NetworkResponse<S, E> {
3333
return when (this) {
3434
is IOException -> NetworkResponse.NetworkError(this)
35-
is HttpException -> extractFromHttpException<S, E>(errorConverter)
35+
is HttpException -> extractFromHttpException<E>(errorConverter)
3636
else -> NetworkResponse.UnknownError(this)
3737
}
3838
}

src/test/kotlin/com/haroldadmin/cnradapter/ErrorExtractionTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal class ErrorExtractionTest: AnnotationSpec() {
2222
val serverResponse = "Server Error".toResponseBody()
2323
val response = Response.error<String>(404, serverResponse)
2424
val exception = HttpException(response)
25-
with(exception.extractFromHttpException<String, String>(errorConverter)) {
25+
with(exception.extractFromHttpException<String>(errorConverter)) {
2626

2727
shouldBeTypeOf<NetworkResponse.ServerError<String>>()
2828
this as NetworkResponse.ServerError

0 commit comments

Comments
 (0)