Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement: use clear error if Git Gateway off #1695

Merged
merged 2 commits into from
Sep 4, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion packages/netlify-cms-backend-git-gateway/src/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,28 @@ export default class GitGateway {
{
headers: { Authorization: `Bearer ${token}` },
},
).then(res => res.json());
).then(async res => {
const contentType = res.headers.get('Content-Type');
if (contentType !== 'application/json' && contentType !== 'text/json') {
throw new APIError(
`Your Git Gateway backend is not returning valid settings. Please make sure it is enabled.`,
res.status,
'Git Gateway',
);
}

const body = await res.json();

if (!res.ok) {
throw new APIError(
`Git Gateway Error: ${body.message ? body.message : body}`,
res.status,
'Git Gateway',
);
}

return body;
});
this.acceptRoles = roles;
if (github_enabled) {
this.backendType = 'github';
Expand Down