Add error message on subscription dashboard if v1 is down (instead of returning a 500 error page) (#7947)

* Add error message on subscription dashboard if v1 is down

GitOrigin-RevId: 8c8b5ac4d44cfd2c42101efe1d55a5993ca21eea
This commit is contained in:
Thomas 2022-05-19 16:25:28 +02:00 committed by Copybot
parent b152956715
commit 35073d49dc
2 changed files with 29 additions and 13 deletions

View file

@ -11,7 +11,11 @@ const _ = require('underscore')
const async = require('async')
const SubscriptionHelper = require('./SubscriptionHelper')
const { promisify } = require('../../util/promises')
const { InvalidError, NotFoundError } = require('../Errors/Errors')
const {
InvalidError,
NotFoundError,
V1ConnectionError,
} = require('../Errors/Errors')
function buildHostedLink(type) {
return `/user/subscription/recurly/${type}`
@ -109,7 +113,15 @@ function buildUsersSubscriptionViewModel(user, callback) {
SubscriptionLocator.getManagedGroupSubscriptions(user, cb)
},
currentInstitutionsWithLicence(cb) {
InstitutionsGetter.getCurrentInstitutionsWithLicence(user._id, cb)
InstitutionsGetter.getCurrentInstitutionsWithLicence(
user._id,
(error, institutions) => {
if (error instanceof V1ConnectionError) {
return cb(null, false)
}
cb(null, institutions)
}
)
},
managedInstitutions(cb) {
InstitutionsGetter.getManagedInstitutions(user._id, cb)

View file

@ -1,11 +1,15 @@
each institution in currentInstitutionsWithLicence
-hasDisplayedSubscription = true
p
| You have a
|
strong(ng-non-bindable) Professional
|
| #{settings.appName} account as a confirmed member of
|
strong(ng-non-bindable)= institution.name
hr
if currentInstitutionsWithLicence === false
.alert.alert-warning
p Sorry, something went wrong. Subscription information related to institutional affiliations may not be displayed. Please try again later.
else
each institution in currentInstitutionsWithLicence
-hasDisplayedSubscription = true
p
| You have a
|
strong(ng-non-bindable) Professional
|
| #{settings.appName} account as a confirmed member of
|
strong(ng-non-bindable)= institution.name
hr