Combine all known API error messages in a UI error message
This commit is contained in:
parent
161a599c18
commit
ea392ab8ae
|
@ -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,
|
||||||
|
|
Loading…
Reference in New Issue