Combine all known API error messages in a UI error message

This commit is contained in:
Artem Chepurnoy 2024-01-23 14:56:13 +02:00
parent 161a599c18
commit ea392ab8ae
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E
1 changed files with 6 additions and 6 deletions

View File

@ -197,12 +197,12 @@ fun ErrorEntity.toException(
// Auto-format the validation error // Auto-format the validation error
// messages to something user-friendly. // messages to something user-friendly.
val validationError = validationErrors?.toMap()?.format() val validationError = validationErrors?.toMap()?.format()
val generalError = errorModel?.message ?: errorDescription ?: error val message = listOfNotNull(
val message = if (validationError != null) { errorModel?.message,
"$generalError\n\n$validationError" errorDescription,
} else { error,
generalError validationError
} ).joinToString(separator = "\n")
ApiException( ApiException(
exception = exception, exception = exception,
code = code, code = code,