Skip to content

Commit a7267b4

Browse files
Merge pull request #141 from JeffreytheCoder/wrong-pr-number
Add error message for wrong PR number
2 parents 24bea46 + 6731caa commit a7267b4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

github/modals/pullDetailsModal.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,31 @@ export async function pullDetailsModal({
5656
const pullRawData = await http.get(
5757
`https://api.github.com/repos/${data?.repository}/pulls/${data?.number}`
5858
);
59+
60+
// If pullsNumber doesn't exist, notify the user
61+
if (pullRawData.statusCode === 404) {
62+
block.addSectionBlock({
63+
text: {
64+
text: `Pull request #${data?.number} doesn't exist.`,
65+
type: TextObjectType.PLAINTEXT,
66+
},
67+
});
68+
69+
return {
70+
title: {
71+
type: TextObjectType.PLAINTEXT,
72+
text: AppEnum.DEFAULT_TITLE,
73+
},
74+
close: block.newButtonElement({
75+
text: {
76+
type: TextObjectType.PLAINTEXT,
77+
text: "Close",
78+
},
79+
}),
80+
blocks: block.getBlocks(),
81+
};
82+
}
83+
5984
const pullData = pullRawData.data;
6085

6186
const pullRequestFilesRaw = await http.get(

0 commit comments

Comments
 (0)