@@ -92,6 +92,8 @@ def get_object(cls, concerned_object: projects.Project, branch_name: str) -> Bra
9292 except HTTPError as e :
9393 if e .response .status_code == HTTPStatus .NOT_FOUND :
9494 raise exceptions .ObjectNotFound (concerned_object .key , f"Project '{ concerned_object .key } ' not found" )
95+ log .critical ("%s while getting branch '%s' of %s" , util .http_error (e ), branch_name , str (concerned_object ))
96+ raise
9597 for br in data .get ("branches" , []):
9698 if br ["name" ] == branch_name :
9799 return cls .load (concerned_object , branch_name , br )
@@ -130,6 +132,8 @@ def refresh(self) -> Branch:
130132 except HTTPError as e :
131133 if e .response .status_code == HTTPStatus .NOT_FOUND :
132134 raise exceptions .ObjectNotFound (self .key , f"{ str (self )} not found in SonarQube" )
135+ log .critical ("%s while refreshing %s" , util .http_error (e ), str (self ))
136+ raise
133137 for br in data .get ("branches" , []):
134138 if br ["name" ] == self .name :
135139 self ._load (br )
@@ -173,7 +177,7 @@ def is_main(self):
173177 self .refresh ()
174178 return self ._is_main
175179
176- def delete (self ):
180+ def delete (self ) -> bool :
177181 """Deletes a branch
178182
179183 :raises ObjectNotFound: Branch not found for deletion
@@ -185,6 +189,8 @@ def delete(self):
185189 except HTTPError as e :
186190 if e .response .status_code == HTTPStatus .BAD_REQUEST :
187191 log .warning ("Can't delete %s, it's the main branch" , str (self ))
192+ else :
193+ log .critical ("%s while deleting %s" , util .http_error (e ), str (self ))
188194 return False
189195
190196 def new_code (self ) -> str :
@@ -200,8 +206,7 @@ def new_code(self) -> str:
200206 except HTTPError as e :
201207 if e .response .status_code == HTTPStatus .NOT_FOUND :
202208 raise exceptions .ObjectNotFound (self .concerned_object .key , f"{ str (self .concerned_object )} not found" )
203- if e .response .status_code == HTTPStatus .FORBIDDEN :
204- log .error ("Error 403 when getting new code period of %s" , {str (self )})
209+ log .error ("%s while getting new code period of %s" , util .http_error (e ), str (self ))
205210 raise e
206211 for b in data ["newCodePeriods" ]:
207212 new_code = settings .new_code_to_string (b )
@@ -264,6 +269,8 @@ def rename(self, new_name):
264269 except HTTPError as e :
265270 if e .response .status_code == HTTPStatus .NOT_FOUND :
266271 raise exceptions .ObjectNotFound (self .concerned_object .key , f"str{ self .concerned_object } not found" )
272+ log .error ("%s while renaming %s" , util .http_error (e ), str (self ))
273+ raise
267274 _OBJECTS .pop (self .uuid (), None )
268275 self .name = new_name
269276 _OBJECTS [self .uuid ()] = self
@@ -361,8 +368,7 @@ def audit(self, audit_settings: types.ConfigSettings) -> list[Problem]:
361368 except HTTPError as e :
362369 if e .response .status_code == HTTPStatus .FORBIDDEN :
363370 log .error ("Not enough permission to fully audit %s" , str (self ))
364- else :
365- log .error ("HTTP error %s while auditing %s" , str (e ), str (self ))
371+ log .error ("%s while auditing %s, audit skipped" , util .http_error (e ), str (self ))
366372 else :
367373 log .debug ("Branch audit disabled, skipping audit of %s" , str (self ))
368374 return []
0 commit comments