@@ -98,7 +98,10 @@ def list(self, limit: int = 50, skip: int = 0) -> list[User]:
98
98
)
99
99
return [User (user ) for user in response .items ]
100
100
except ApiException as e :
101
- error = handle_api_error (e .status , str (e ), getattr (e , "body" , None ))
101
+ status_code = getattr (e , "status" , None )
102
+ if not isinstance (status_code , int ):
103
+ status_code = 500 # Default to server error if status is not available
104
+ error = handle_api_error (status_code , str (e ), getattr (e , "body" , None ))
102
105
raise error from e
103
106
104
107
def list_all (self , page_size : int = 50 ) -> Iterator [User ]:
@@ -145,7 +148,10 @@ def get(self, user_id: int | str) -> User:
145
148
response = self .users_api .get_user_v1_organizations_org_id_users_user_id_get (org_id = self .org_id , user_id = str (user_id ), authorization = f"Bearer { self .token } " )
146
149
return User (response )
147
150
except ApiException as e :
148
- error = handle_api_error (e .status , str (e ), getattr (e , "body" , None ))
151
+ status_code = getattr (e , "status" , None )
152
+ if not isinstance (status_code , int ):
153
+ status_code = 500 # Default to server error if status is not available
154
+ error = handle_api_error (status_code , str (e ), getattr (e , "body" , None ))
149
155
raise error from e
150
156
151
157
def get_page (self , page : int = 1 , page_size : int = 50 ) -> dict [str , Any ]:
@@ -174,7 +180,10 @@ def get_page(self, page: int = 1, page_size: int = 50) -> dict[str, Any]:
174
180
175
181
return {"items" : [User (user ) for user in response .items ], "total" : response .total , "page" : response .page , "size" : response .size , "pages" : response .pages }
176
182
except ApiException as e :
177
- error = handle_api_error (e .status , str (e ), getattr (e , "body" , None ))
183
+ status_code = getattr (e , "status" , None )
184
+ if not isinstance (status_code , int ):
185
+ status_code = 500 # Default to server error if status is not available
186
+ error = handle_api_error (status_code , str (e ), getattr (e , "body" , None ))
178
187
raise error from e
179
188
180
189
def find_by_github_username (self , github_username : str ) -> User | None :
0 commit comments