diff --git a/packages/reg-notify-gitlab-plugin/src/gitlab-api-client.ts b/packages/reg-notify-gitlab-plugin/src/gitlab-api-client.ts index 64407b3f..41ce6060 100644 --- a/packages/reg-notify-gitlab-plugin/src/gitlab-api-client.ts +++ b/packages/reg-notify-gitlab-plugin/src/gitlab-api-client.ts @@ -83,6 +83,9 @@ export class DefaultGitLabApiClient implements GitLabApiClient { "Private-Token": this._token, }, }); + if (400 <= res.status) { + throw new Error(`HTTP ${res.status}: Failed to request.`); + } return res.json() as any as Promise; } @@ -92,9 +95,13 @@ export class DefaultGitLabApiClient implements GitLabApiClient { method: "PUT", headers: { "Private-Token": this._token, + "Content-Type": "application/json", }, body: JSON.stringify(params), }); + if (400 <= res.status) { + throw new Error(`HTTP ${res.status}: Failed to request.`); + } return res.json() as any as Promise; } @@ -108,6 +115,9 @@ export class DefaultGitLabApiClient implements GitLabApiClient { }, }, ); + if (400 <= res.status) { + throw new Error(`HTTP ${res.status}: Failed to request.`); + } return res.json() as any as Promise; } @@ -120,6 +130,9 @@ export class DefaultGitLabApiClient implements GitLabApiClient { }, }, ); + if (400 <= res.status) { + throw new Error(`HTTP ${res.status}: Failed to request.`); + } return res.json() as any as Promise; } @@ -131,12 +144,16 @@ export class DefaultGitLabApiClient implements GitLabApiClient { method: "POST", headers: { "Private-Token": this._token, + "Content-Type": "application/json", }, body: JSON.stringify({ body: params.body, }), }, ); + if (400 <= res.status) { + throw new Error(`HTTP ${res.status}: Failed to request.`); + } return res.json() as any as Promise; } @@ -148,12 +165,16 @@ export class DefaultGitLabApiClient implements GitLabApiClient { method: "PUT", headers: { "Private-Token": this._token, + "Content-Type": "application/json", }, body: JSON.stringify({ body: params.body, }), }, ); + if (400 <= res.status) { + throw new Error(`HTTP ${res.status}: Failed to request.`); + } return res.json() as any as Promise; } @@ -165,12 +186,16 @@ export class DefaultGitLabApiClient implements GitLabApiClient { method: "POST", headers: { "Private-Token": this._token, + "Content-Type": "application/json", }, body: JSON.stringify({ body: params.body, }), }, ); + if (400 <= res.status) { + throw new Error(`HTTP ${res.status}: Failed to request.`); + } return res.json() as any as Promise; }