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
// messages to something user-friendly.
val validationError = validationErrors?.toMap()?.format()
val generalError = errorModel?.message ?: errorDescription ?: error
val message = if (validationError != null) {
"$generalError\n\n$validationError"
} else {
generalError
}
val message = listOfNotNull(
errorModel?.message,
errorDescription,
error,
validationError
).joinToString(separator = "\n")
ApiException(
exception = exception,
code = code,