Skip to content

Commit

Permalink
Added missing error message handler for the integrity token endpoint (#…
Browse files Browse the repository at this point in the history
…22043)

ref https://linear.app/ghost/issue/PRO-1349

- the integrity token endpoint can return a json response with an error
message (for example, when rate limited)
- added the standard response handler to the integrity token endpoint in
Portal, to render the error message sent by the backend
  • Loading branch information
sagzy authored Jan 22, 2025
1 parent 3a38aef commit f07291b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/portal/src/utils/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ function setupGhostApi({siteUrl = window.location.origin, apiUrl, apiKey}) {
if (res.ok) {
return res.text();
} else {
const humanError = await HumanReadableError.fromApiResponse(res);
if (humanError) {
throw humanError;
}
throw new Error('Failed to start a members session');
}
},
Expand Down Expand Up @@ -290,7 +294,6 @@ function setupGhostApi({siteUrl = window.location.origin, apiUrl, apiKey}) {
if (res.ok) {
return 'Success';
} else {
// Try to read body error message that is human readable and should be shown to the user
const humanError = await HumanReadableError.fromApiResponse(res);
if (humanError) {
throw humanError;
Expand Down

0 comments on commit f07291b

Please sign in to comment.