diff --git a/lib/cli-create.ts b/lib/cli-create.ts index 8916775..a102f83 100644 --- a/lib/cli-create.ts +++ b/lib/cli-create.ts @@ -36,9 +36,9 @@ export async function createAction(options: CreateOptions) { if (response instanceof AxiosError) { throw response; } - if (response.status / 100 === 2) { + if (response.status / 100 !== 2) { console.error(`Failed to create merge request: ${JSON.stringify(response.data)}, Status ${response.status}`); - throw new Error(`Failed to accept merge request`); + process.exit(1); } console.log(JSON.stringify(response.data)); } diff --git a/lib/cli-list.ts b/lib/cli-list.ts index c28991d..f7eb14c 100644 --- a/lib/cli-list.ts +++ b/lib/cli-list.ts @@ -32,9 +32,9 @@ export async function listAction(options: ListOptions) { if (response instanceof AxiosError) { throw response; } - if (response.status / 100 === 2) { - console.error(`Failed to create merge request: ${JSON.stringify(response.data)}, Status ${response.status}`); - throw new Error(`Failed to accept merge request`); + if (response.status / 100 !== 2) { + console.error(`Failed to list merge requests: ${JSON.stringify(response.data)}, Status ${response.status}`); + process.exit(1); } console.log(JSON.stringify(response.data)); } diff --git a/lib/cli-merge.ts b/lib/cli-merge.ts index 4f94c17..5e5a0de 100644 --- a/lib/cli-merge.ts +++ b/lib/cli-merge.ts @@ -33,9 +33,9 @@ export async function mergeAction(options: AcceptOptions) { if (response instanceof AxiosError) { throw response; } - if (response.status / 100 === 2) { + if (response.status / 100 !== 2) { console.error(`Failed to accept merge request: ${JSON.stringify(response.data)}, Status ${response.status}`); - throw new Error(`Failed to accept merge request`); + process.exit(1); } console.log(`Merge request ${mergeRequestIid} is accepted`); }