Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/src/main/java/app/waveflow/data/remote/ServerHttp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ServerHttp(
return withContext(Dispatchers.IO) {
try {
client.newCall(request).await().use {
if (it.isSuccessful) it.body?.string().orEmpty() else throw it.toException()
if (it.isSuccessful) it.body.string() else throw it.toException()
}
} catch (broken: IOException) {
// Une coupure pendant la lecture du corps lève ici, et non dans
Expand Down Expand Up @@ -159,7 +159,7 @@ class ServerHttp(
// Le serveur répond `{code, message}` sur ses erreurs métier, mais un
// corps mal formé lui fait renvoyer du texte brut : lire le message
// sans supposer du JSON.
val raw = body?.string().orEmpty()
val raw = body.string()
val message = runCatching { json.decodeFromString<ErrorBody>(raw).message }
.getOrNull()
?: raw.ifBlank { "Erreur $code" }
Expand Down