Skip to content

Commit

Permalink
fix: added error handling if google is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
dmengelt committed May 2, 2023
1 parent 0627cb9 commit c584c0a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/lib/button-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,16 @@ export class ButtonManager {
// remove existing button
this.removeButton();

this.client = new google.payments.api.PaymentsClient(this.createClientOptions(this.config));
try {
this.client = new google.payments.api.PaymentsClient(this.createClientOptions(this.config));
} catch (err) {
if (this.config.onError) {
this.config.onError(err as Error);
} else {
console.error(err);
}
return;
}

const buttonOptions: google.payments.api.ButtonOptions = {
buttonType: this.config.buttonType,
Expand Down

0 comments on commit c584c0a

Please sign in to comment.