Skip to content

Commit

Permalink
Add error message for unparseable checkConsentHref response (#29696)
Browse files Browse the repository at this point in the history
* init

* Try catch
  • Loading branch information
Micajuine Ho committed Sep 4, 2020
1 parent 63848d3 commit 2ff4363
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions extensions/amp-consent/0.1/amp-consent.js
Expand Up @@ -607,11 +607,19 @@ export class AmpConsent extends AMP.BaseElement {
return ampdoc.whenFirstVisible().then(() => {
return expandConsentEndpointUrl(this.element, resolvedHref).then(
(expandedHref) => {
return xhrService
.fetchJson(expandedHref, init)
.then((res) =>
xhrService.xssiJson(res, this.consentConfig_['xssiPrefix'])
);
return xhrService.fetchJson(expandedHref, init).then((res) => {
try {
return xhrService.xssiJson(
res,
this.consentConfig_['xssiPrefix']
);
} catch (e) {
userAssert(
false,
'Could not parse the `checkConsentHref` response.'
);
}
});
}
);
});
Expand Down

0 comments on commit 2ff4363

Please sign in to comment.