From 6731caae80e764f8218364fb5413b8a51ee3d559 Mon Sep 17 00:00:00 2001 From: Jeffrey Yu <35394596+JeffreytheCoder@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:10:59 -0800 Subject: [PATCH] Add error message for wrong PR number --- github/modals/pullDetailsModal.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/github/modals/pullDetailsModal.ts b/github/modals/pullDetailsModal.ts index 13d9154..e57db23 100644 --- a/github/modals/pullDetailsModal.ts +++ b/github/modals/pullDetailsModal.ts @@ -56,6 +56,31 @@ export async function pullDetailsModal({ const pullRawData = await http.get( `https://api.github.com/repos/${data?.repository}/pulls/${data?.number}` ); + + // If pullsNumber doesn't exist, notify the user + if (pullRawData.statusCode === 404) { + block.addSectionBlock({ + text: { + text: `Pull request #${data?.number} doesn't exist.`, + type: TextObjectType.PLAINTEXT, + }, + }); + + return { + title: { + type: TextObjectType.PLAINTEXT, + text: AppEnum.DEFAULT_TITLE, + }, + close: block.newButtonElement({ + text: { + type: TextObjectType.PLAINTEXT, + text: "Close", + }, + }), + blocks: block.getBlocks(), + }; + } + const pullData = pullRawData.data; const pullRequestFilesRaw = await http.get(