Add error handling (WIP)

This commit is contained in:
Emili Castells Guasch 2023-11-13 17:03:04 +01:00
parent 822485f782
commit b2a8c607af

View file

@ -179,6 +179,7 @@ class CreditCardRenderer {
},
onError: function (error) {
console.error(error)
this.spinner.unblock();
}
});
@ -205,7 +206,15 @@ class CreditCardRenderer {
document.querySelector(buttonSelector).addEventListener("click", (event) => {
event.preventDefault();
cardField.submit();
this.spinner.block();
this.errorHandler.clear();
cardField.submit()
.catch((error) => {
this.spinner.unblock();
console.error(error)
this.errorHandler.genericError();
})
});
return;
@ -325,4 +334,5 @@ class CreditCardRenderer {
element.setAttribute('class', newClassName);
}
}
export default CreditCardRenderer;