From 8c3473e5e03d04bbd4302926f19bc1818bf797a7 Mon Sep 17 00:00:00 2001 From: Naz Date: Mon, 25 Jul 2022 13:53:53 +0100 Subject: [PATCH] Moved exception handling for members migrations refs https://github.com/TryGhost/Toolbox/issues/358 - Error handling should be done as close to the place that knows how to handle them. It's a catch-all block which doesn't add any logic, so does not really make sense to have that extra code in general "init" method which ideally should be just a whole bunch of calls with no extras. --- .../core/server/services/members/service.js | 6 +---- ghost/stripe/lib/Migrations.js | 24 +++++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ghost/core/core/server/services/members/service.js b/ghost/core/core/server/services/members/service.js index e1ecbe7eac..dfc7a3cac7 100644 --- a/ghost/core/core/server/services/members/service.js +++ b/ghost/core/core/server/services/members/service.js @@ -148,11 +148,7 @@ module.exports = { } })(); - try { - await stripeService.migrations.execute(); - } catch (err) { - logging.error(err); - } + await stripeService.migrations.execute(); }, contentGating: require('./content-gating'), diff --git a/ghost/stripe/lib/Migrations.js b/ghost/stripe/lib/Migrations.js index a1c6adcde5..684b648d45 100644 --- a/ghost/stripe/lib/Migrations.js +++ b/ghost/stripe/lib/Migrations.js @@ -27,16 +27,20 @@ module.exports = class StripeMigrations { return; } - await this.populateProductsAndPrices(); - await this.populateStripePricesFromStripePlansSetting(); - await this.populateMembersMonthlyPriceIdSettings(); - await this.populateMembersYearlyPriceIdSettings(); - await this.populateDefaultProductMonthlyPriceId(); - await this.populateDefaultProductYearlyPriceId(); - await this.revertPortalPlansSetting(); - await this.removeInvalidSubscriptions(); - await this.setDefaultProductName(); - await this.updateStripeProductNamesFromDefaultProduct(); + try { + await this.populateProductsAndPrices(); + await this.populateStripePricesFromStripePlansSetting(); + await this.populateMembersMonthlyPriceIdSettings(); + await this.populateMembersYearlyPriceIdSettings(); + await this.populateDefaultProductMonthlyPriceId(); + await this.populateDefaultProductYearlyPriceId(); + await this.revertPortalPlansSetting(); + await this.removeInvalidSubscriptions(); + await this.setDefaultProductName(); + await this.updateStripeProductNamesFromDefaultProduct(); + } catch (err) { + logging.error(err); + } } async populateProductsAndPrices(options) {