add better error handling to tax call (#1666)

This commit is contained in:
Jake Fink 2022-05-11 11:13:42 -04:00 committed by GitHub
parent da470ad709
commit dc2078ae58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 7 deletions

View File

@ -73,11 +73,15 @@ export class TaxInfoComponent {
this.logService.error(e); this.logService.error(e);
} }
} else { } else {
try {
const taxInfo = await this.apiService.getTaxInfo(); const taxInfo = await this.apiService.getTaxInfo();
if (taxInfo) { if (taxInfo) {
this.taxInfo.postalCode = taxInfo.postalCode; this.taxInfo.postalCode = taxInfo.postalCode;
this.taxInfo.country = taxInfo.country || "US"; this.taxInfo.country = taxInfo.country || "US";
} }
} catch (e) {
this.logService.error(e);
}
} }
this.pristine = Object.assign({}, this.taxInfo); this.pristine = Object.assign({}, this.taxInfo);
// If not the default (US) then trigger onCountryChanged // If not the default (US) then trigger onCountryChanged
@ -86,10 +90,17 @@ export class TaxInfoComponent {
} }
}); });
try {
const taxRates = await this.apiService.getTaxRates(); const taxRates = await this.apiService.getTaxRates();
if (taxRates) {
this.taxRates = taxRates.data; this.taxRates = taxRates.data;
}
} catch (e) {
this.logService.error(e);
} finally {
this.loading = false; this.loading = false;
} }
}
get taxRate() { get taxRate() {
if (this.taxRates != null) { if (this.taxRates != null) {