From 6a250106a742f5185b82946ebc8f54889a0818f7 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 20 Apr 2022 16:49:44 +0200 Subject: [PATCH] display warning for errors calling the github Signed-off-by: Johan Haals --- .../src/commands/create-github-app/index.ts | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/commands/create-github-app/index.ts b/packages/cli/src/commands/create-github-app/index.ts index 617ae12f36..32fa1e9a6d 100644 --- a/packages/cli/src/commands/create-github-app/index.ts +++ b/packages/cli/src/commands/create-github-app/index.ts @@ -51,10 +51,22 @@ integrations: }; async function verifyGithubOrg(org: string): Promise { - const response = await fetch( - `https://api.github.com/orgs/${encodeURIComponent(org)}`, - ); - if (!response.ok) { + let response; + + try { + response = await fetch( + `https://api.github.com/orgs/${encodeURIComponent(org)}`, + ); + } catch (e) { + console.log( + chalk.yellow( + 'Warning: Unable to verify existence of GitHub organization. ', + e, + ), + ); + } + + if (response?.status === 404) { throw new Error( `GitHub organization '${org}' does not exist. Please verify the name and try again.`, );