Skip to content

Commit a6fd185

Browse files
committed
handle bad request response
1 parent 84968d5 commit a6fd185

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

mobile/shared/src/commonMain/kotlin/com/ktnotes/di/networkModule.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.ktnotes.di
22

3+
import com.ktnotes.exception.BadRequestException
34
import com.ktnotes.feature.auth.model.AuthResponse
45
import com.ktnotes.feature.auth.model.RefreshTokenRequest
56
import com.ktnotes.helper.postWithJsonContent
@@ -103,7 +104,7 @@ fun createHttpClient(
103104
validateResponse { response: HttpResponse ->
104105
if (response.status == HttpStatusCode.BadRequest && response.contentType() == ContentType.Application.Json) {
105106
val messageResponse = Json.decodeFromString<MessageResponse>(response.body())
106-
throw Exception(messageResponse.message)
107+
throw BadRequestException(messageResponse.message)
107108
}
108109
}
109110
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package com.ktnotes.exception
2+
3+
data class BadRequestException(override val message:String):Exception(message)

0 commit comments

Comments
 (0)