fix(cards): propagate API validation error message to user on card submit failure
This commit is contained in:
@@ -1217,6 +1217,14 @@ struct PaymentCardView: View {
|
|||||||
guard let result = response.result else { return }
|
guard let result = response.result else { return }
|
||||||
let orderId = result.id ?? UUID().uuidString
|
let orderId = result.id ?? UUID().uuidString
|
||||||
onOrderCreated(orderId, result.shortId)
|
onOrderCreated(orderId, result.shortId)
|
||||||
|
} catch let error as NetworkError {
|
||||||
|
let message: String
|
||||||
|
if case .httpError(_, let serverMessage) = error, let serverMessage, serverMessage.isEmpty == false {
|
||||||
|
message = serverMessage
|
||||||
|
} else {
|
||||||
|
message = error.errorDescription ?? "Não foi possível processar o pagamento."
|
||||||
|
}
|
||||||
|
SnackbarCenter.shared.show(title: message, style: .error, icon: "xmark.octagon.fill", duration: 5.0)
|
||||||
} catch {
|
} catch {
|
||||||
SnackbarCenter.shared.show(title: "Não foi possível processar o pagamento.", style: .error, icon: "xmark.octagon.fill", duration: 3.0)
|
SnackbarCenter.shared.show(title: "Não foi possível processar o pagamento.", style: .error, icon: "xmark.octagon.fill", duration: 3.0)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user