@@ -16,13 +16,22 @@ async function getPRDetails() {
1616}
1717
1818async function getIssueDetails ( issueNumber ) {
19- const url = `https://api.github.com/repos/${ owner } /${ repo } /issues/${ issueNumber } ` ;
20- const response = await axios . get ( url , {
21- headers : {
22- Authorization : `token ${ githubToken } `
19+ try {
20+ const url = `https://api.github.com/repos/${ owner } /${ repo } /issues/${ issueNumber } ` ;
21+ const response = await axios . get ( url , {
22+ headers : {
23+ Authorization : `token ${ githubToken } `
24+ }
25+ } ) ;
26+ return response . data ;
27+ } catch ( error ) {
28+ if ( error . response && error . response . status === 404 ) {
29+ console . log ( `Issue #${ issueNumber } not found, skipping...` ) ;
30+ return null ;
31+ } else {
32+ throw error ;
2333 }
24- } ) ;
25- return response . data ;
34+ }
2635}
2736
2837async function run ( ) {
@@ -45,13 +54,15 @@ async function run() {
4554 for ( const match of issueNumberMatches ) {
4655 const issueNumber = match . replace ( '#' , '' ) ;
4756 const issue = await getIssueDetails ( issueNumber ) ;
48- const { labels : issueLabels , milestone : issueMilestone } = issue ;
57+ if ( issue ) {
58+ const { labels : issueLabels , milestone : issueMilestone } = issue ;
4959
50- if ( issueLabels . length === 0 ) {
51- throw new Error ( `Associated issue #${ issueNumber } has no labels.` ) ;
52- }
53- if ( ! issueMilestone ) {
54- throw new Error ( `Associated issue #${ issueNumber } has no milestone.` ) ;
60+ if ( issueLabels . length === 0 ) {
61+ throw new Error ( `Associated issue #${ issueNumber } has no labels.` ) ;
62+ }
63+ if ( ! issueMilestone ) {
64+ throw new Error ( `Associated issue #${ issueNumber } has no milestone.` ) ;
65+ }
5566 }
5667 }
5768 }
0 commit comments