@@ -80,33 +80,50 @@ def wait_for_api_refresh(
80
80
if idx % issues_per_page == 0 :
81
81
wait_for_api_refresh (issues_iterator , rate_limit_bypass )
82
82
83
- except github3 .exceptions .ForbiddenError :
83
+ except github3 .exceptions .ForbiddenError as e :
84
84
print (
85
85
f"You do not have permission to view a repository \
86
86
from: '{ repos_and_owners_string } '; Check your API Token."
87
87
)
88
+ print_error_messages (e )
88
89
sys .exit (1 )
89
- except github3 .exceptions .NotFoundError :
90
+ except github3 .exceptions .NotFoundError as e :
90
91
print (
91
92
f"The repository could not be found; \
92
93
Check the repository owner and names: '{ repos_and_owners_string } "
93
94
)
95
+ print_error_messages (e )
94
96
sys .exit (1 )
95
- except github3 .exceptions .ConnectionError :
97
+ except github3 .exceptions .ConnectionError as e :
96
98
print (
97
99
"There was a connection error; Check your internet connection or API Token."
98
100
)
101
+ print_error_messages (e )
99
102
sys .exit (1 )
100
- except github3 .exceptions .AuthenticationFailed :
103
+ except github3 .exceptions .AuthenticationFailed as e :
101
104
print ("Authentication failed; Check your API Token." )
105
+ print_error_messages (e )
102
106
sys .exit (1 )
103
- except github3 .exceptions .UnprocessableEntity :
107
+ except github3 .exceptions .UnprocessableEntity as e :
104
108
print ("The search query is invalid; Check the search query." )
109
+ print_error_messages (e )
105
110
sys .exit (1 )
106
111
107
112
return issues
108
113
109
114
115
+ def print_error_messages (error : github3 .exceptions ):
116
+ """Prints the error messages from the GitHub API response.
117
+
118
+ Args:
119
+ Error (github3.exceptions): The error object from the GitHub API response.
120
+
121
+ """
122
+ if hasattr (error , "errors" ):
123
+ for e in error .errors :
124
+ print (f"Error: { e .get ('message' )} " )
125
+
126
+
110
127
def get_owners_and_repositories (
111
128
search_query : str ,
112
129
) -> List [dict ]:
0 commit comments