Skip to content

Commit

Permalink
fix: invalid token & better error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-Fabi committed Jul 20, 2024
1 parent 307b375 commit 6bdcc2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.datepollsystems.waiterrobot.mediator.data.api.ApiException
fun HttpClientConfig<*>.installApiClientExceptionTransformer(json: Json, logger: Logger) {
expectSuccess = true
HttpResponseValidator {
handleResponseExceptionWithRequest { exception, _ ->
handleResponseExceptionWithRequest { exception, request ->
val clientException =
exception as? ClientRequestException ?: return@handleResponseExceptionWithRequest

Expand All @@ -21,7 +21,10 @@ fun HttpClientConfig<*>.installApiClientExceptionTransformer(json: Json, logger:
throw try {
json.decodeFromString<ApiException>(jsonString)
} catch (e: SerializationException) {
logger.w(e) { "Could not serialize ClientError using fallback" }
logger.w(e) {
"Could not serialize ClientError using fallback.\n" +
"\t(${request.method.value}: ${request.url}, ${clientException.response.status} '$jsonString')"
}
try {
json.decodeFromString<ApiException.Generic>(jsonString)
} catch (_: SerializationException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fun HttpClientConfig<*>.configureAuth(enableNetworkLogs: Boolean, logger: Logger
} catch (e: Exception) {
// TODO improve request errors handling (-> try again, logout?, no connection info)
logger.e(e) { "Error while refreshing token: ${e.message}" }
App.logout()
null
}
}
Expand Down

0 comments on commit 6bdcc2d

Please sign in to comment.