Merge pull request #1035 from woocommerce/pcp-1036-fix-dcc-messages

Fix DCC error messages handling
This commit is contained in:
Emili Castells 2022-11-30 16:32:26 +01:00 committed by GitHub
commit 67559a0492
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View file

@ -59,9 +59,9 @@ class CheckoutActionHandler {
);
} else {
errorHandler.clear();
if (data.data.errors.length > 0) {
if (data.data.errors?.length > 0) {
errorHandler.messages(data.data.errors);
} else if (data.data.details.length > 0) {
} else if (data.data.details?.length > 0) {
errorHandler.message(data.data.details.map(d => `${d.issue} ${d.description}`).join('<br/>'), true);
} else {
errorHandler.message(data.data.message, true);

View file

@ -233,8 +233,14 @@ class CreditCardRenderer {
this.spinner.unblock();
this.errorHandler.clear();
if (err.details?.length) {
if (err.data?.details?.length) {
this.errorHandler.message(err.data.details.map(d => `${d.issue} ${d.description}`).join('<br/>'), true);
} else if (err.details?.length) {
this.errorHandler.message(err.details.map(d => `${d.issue} ${d.description}`).join('<br/>'), true);
} else if (err.data?.errors?.length > 0) {
this.errorHandler.messages(err.data.errors);
} else if (err.data?.message) {
this.errorHandler.message(err.data.message, true);
} else if (err.message) {
this.errorHandler.message(err.message, true);
} else {