Skip to content

Commit 26a4f21

Browse files
committed
Improve sub cancellation error handling
1 parent 78ac7d0 commit 26a4f21

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/components/settings/settings-page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,6 @@ class SettingsPage extends React.Component<SettingsPageProps> {
368368

369369
this.props.accountStore.cancelSubscription().catch((e) => {
370370
alert(e.message);
371-
reportError(e);
372371
});
373372
};
374373
}

src/model/account/account-store.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -317,16 +317,21 @@ export class AccountStore {
317317
}
318318

319319
cancelSubscription = flow(function * (this: AccountStore) {
320-
yield cancelSubscription();
321-
322-
console.log('Subscription cancel requested');
323-
this.isAccountUpdateInProcess = true;
324-
yield this.waitForUserUpdate(() =>
325-
!this.user.subscription ||
326-
this.user.subscription.status === 'deleted'
327-
);
328-
this.isAccountUpdateInProcess = false;
329-
console.log('Subscription cancellation confirmed');
320+
try {
321+
this.isAccountUpdateInProcess = true;
322+
yield cancelSubscription();
323+
yield this.waitForUserUpdate(() =>
324+
!this.user.subscription ||
325+
this.user.subscription.status === 'deleted'
326+
);
327+
console.log('Subscription cancellation confirmed');
328+
} catch (e: any) {
329+
console.log(e);
330+
reportError(`Subscription cancellation failed: ${e.message || e}`);
331+
throw e;
332+
} finally {
333+
this.isAccountUpdateInProcess = false;
334+
}
330335
});
331336

332337
}

0 commit comments

Comments
 (0)