diff --git a/openedx/features/course_experience/static/course_experience/js/currency.js b/openedx/features/course_experience/static/course_experience/js/currency.js index aa9f6e5595..1f1cd9a1bf 100644 --- a/openedx/features/course_experience/static/course_experience/js/currency.js +++ b/openedx/features/course_experience/static/course_experience/js/currency.js @@ -28,7 +28,18 @@ export class Currency { // eslint-disable-line import/prefer-default-export } getCountry() { - this.countryL10nData = JSON.parse($.cookie('edx-price-l10n')); + try { + this.countryL10nData = JSON.parse($.cookie('edx-price-l10n')); + } catch (e) { + if (e instanceof SyntaxError) { + // If cookie isn't proper JSON, log but continue. This will show the purchase experience + // in a non-local currency but will not prevent the user from interacting with the page. + console.error(e); + console.error("Ignoring malformed 'edx-price-l10n' cookie."); + } else { + throw e; + } + } if (this.countryL10nData) { window.analytics.track('edx.bi.user.track_selection.local_currency_cookie_set'); this.setPrice();