File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -69,6 +69,22 @@ async function fetchDiscussions() {
6969 } ) ;
7070
7171 const data = await response . json ( ) ;
72+
73+ // Check for API errors in the response
74+ if ( data . errors ) {
75+ console . error ( "GitHub API returned errors:" , JSON . stringify ( data . errors , null , 2 ) ) ;
76+ throw new Error ( "Failed to fetch discussions due to API errors." ) ;
77+ }
78+
79+ // Check for unexpected data structure
80+ if ( ! data . data || ! data . data . repository || ! data . data . repository . discussionCategory ) {
81+ console . error ( "Unexpected data structure from GitHub API:" , JSON . stringify ( data , null , 2 ) ) ;
82+ if ( data . data && data . data . repository && ! data . data . repository . discussionCategory ) {
83+ throw new Error ( `Could not find the discussion category: '${ DISCUSSION_CATEGORY_NAME } '. Please check the name.` ) ;
84+ }
85+ throw new Error ( "Unexpected data structure received from GitHub API." ) ;
86+ }
87+
7288 return data . data . repository . discussionCategory . discussions . nodes ;
7389}
7490
You can’t perform that action at this time.
0 commit comments