Skip to content

Commit ed68231

Browse files
committed
Change http_error in error_msg
1 parent ac9f6c3 commit ed68231

24 files changed

+62
-62
lines changed

cli/findings_export.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def __get_component_findings(queue: Queue[tuple[object, ConfigSettings]], write_
295295
component.endpoint, component.key, branch=params.get("branch", None), pull_request=params.get("pullRequest", None)
296296
)
297297
except (HTTPError, ConnectionError, RequestException) as e:
298-
log.critical("%s while exporting findings of %s, skipped", util.http_error(e), str(component))
298+
log.critical("%s while exporting findings of %s, skipped", util.error_msg(e), str(component))
299299
findings_list = {}
300300
write_queue.put([findings_list, False])
301301
else:
@@ -324,7 +324,7 @@ def __get_component_findings(queue: Queue[tuple[object, ConfigSettings]], write_
324324
try:
325325
findings_list = component.get_issues(filters=new_params)
326326
except (HTTPError, ConnectionError, RequestException) as e:
327-
log.critical("%s while exporting issues of %s, skipped", util.http_error(e), str(component))
327+
log.critical("%s while exporting issues of %s, skipped", util.error_msg(e), str(component))
328328
findings_list = {}
329329
else:
330330
log.debug("Status = %s, Types = %s, Resol = %s, Sev = %s", str(i_statuses), str(i_types), str(i_resols), str(i_sevs))
@@ -334,7 +334,7 @@ def __get_component_findings(queue: Queue[tuple[object, ConfigSettings]], write_
334334
try:
335335
findings_list.update(component.get_hotspots(filters=new_params))
336336
except (HTTPError, ConnectionError, RequestException) as e:
337-
log.error("%s while exporting hotspots of object key %s, skipped", util.http_error(e), str(component))
337+
log.error("%s while exporting hotspots of object key %s, skipped", util.error_msg(e), str(component))
338338
else:
339339
log.debug("Status = %s, Types = %s, Resol = %s, Sev = %s", str(h_statuses), str(h_types), str(h_resols), str(h_sevs))
340340
log.info("Selected types, severities, resolutions or statuses disables issue search")
@@ -352,7 +352,7 @@ def store_findings(components_list: dict[str, object], params: ConfigSettings) -
352352
log.debug("Queue %s task %s put", str(my_queue), str(comp))
353353
my_queue.put((comp, params.copy()))
354354
except (HTTPError, ConnectionError, RequestException) as e:
355-
log.critical("%s while exporting findings of %s, skipped", util.http_error(e), str(comp))
355+
log.critical("%s while exporting findings of %s, skipped", util.error_msg(e), str(comp))
356356

357357
threads = params.get(options.NBR_THREADS, 4)
358358
for i in range(min(threads, len(components_list))):

cli/loc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __get_csv_row(o: object, **kwargs) -> tuple[list[str], str]:
5252
try:
5353
loc = o.loc()
5454
except (HTTPError, ConnectionError, RequestException) as e:
55-
log.warning("%s, LoC export of %s skipped", util.http_error(e), str(o))
55+
log.warning("%s, LoC export of %s skipped", util.error_msg(e), str(o))
5656
loc = ""
5757
arr = [o.key, loc]
5858
obj_type = type(o).__name__.lower()
@@ -114,7 +114,7 @@ def __get_object_json_data(o: object, **kwargs) -> dict[str, str]:
114114
try:
115115
d["ncloc"] = o.loc()
116116
except (HTTPError, ConnectionError, RequestException) as e:
117-
log.warning("%s, LoC export of %s skipped", util.http_error(e), str(o))
117+
log.warning("%s, LoC export of %s skipped", util.error_msg(e), str(o))
118118
if kwargs[options.WITH_NAME]:
119119
d[f"{parent_type}Name"] = o.name
120120
if obj_type in ("branch", "applicationbranch"):

cli/measures_export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def __get_measures(obj: object, wanted_metrics: types.KeyList, hist: bool) -> Un
283283
else:
284284
data.update(__get_object_measures(obj, wanted_metrics))
285285
except (HTTPError, ConnectionError, RequestException) as e:
286-
log.error("%s, measures export skipped for %s", util.http_error(e), str(obj))
286+
log.error("%s, measures export skipped for %s", util.error_msg(e), str(obj))
287287
return None
288288
return data
289289

sonar/app_branches.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def create(cls, app: App, name: str, project_branches: list[Branch]) -> Applicat
112112
except (HTTPError, ConnectionError, RequestException) as e:
113113
if e.response.status_code == HTTPStatus.BAD_REQUEST:
114114
raise exceptions.ObjectAlreadyExists(f"app.App {app.key} branch '{name}", e.response.text)
115-
log.critical("%s while creating branch '%s' of '%s'", utilities.http_error(e), name, str(app))
115+
log.critical("%s while creating branch '%s' of '%s'", utilities.error_msg(e), name, str(app))
116116
raise
117117
return ApplicationBranch(app=app, name=name, project_branches=project_branches)
118118

@@ -187,7 +187,7 @@ def update(self, name: str, project_branches: list[Branch]) -> bool:
187187
except (HTTPError, ConnectionError, RequestException) as e:
188188
if e.response.status_code == HTTPStatus.NOT_FOUND:
189189
raise exceptions.ObjectNotFound(str(self), e.response.text)
190-
log.error("%s while updating '%s'", utilities.http_error(e), str(self))
190+
log.error("%s while updating '%s'", utilities.error_msg(e), str(self))
191191
raise
192192

193193
self.name = name

sonar/applications.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def get_object(cls, endpoint: pf.Platform, key: str) -> Application:
9393
except (HTTPError, ConnectionError, RequestException) as e:
9494
if e.response.status_code == HTTPStatus.NOT_FOUND:
9595
raise exceptions.ObjectNotFound(key, f"Application key '{key}' not found")
96-
log.error("%s while getting app key '%s'", util.http_error(e), key)
96+
log.error("%s while getting app key '%s'", util.error_msg(e), key)
9797
raise
9898
return cls.load(endpoint, data)
9999

@@ -136,7 +136,7 @@ def create(cls, endpoint: pf.Platform, key: str, name: str) -> Application:
136136
except (HTTPError, ConnectionError, RequestException) as e:
137137
if e.response.status_code == HTTPStatus.BAD_REQUEST:
138138
raise exceptions.ObjectAlreadyExists(key, e.response.text)
139-
log.critical("%s while creating app key '%s'", util.http_error(e), key)
139+
log.critical("%s while creating app key '%s'", util.error_msg(e), key)
140140
raise
141141
return Application(endpoint, key, name)
142142

@@ -154,7 +154,7 @@ def refresh(self) -> None:
154154
if e.response.status_code == HTTPStatus.NOT_FOUND:
155155
_OBJECTS.pop(self.uuid(), None)
156156
raise exceptions.ObjectNotFound(self.key, f"{str(self)} not found")
157-
log.error("%s while refreshing %s", util.http_error(e), str(self))
157+
log.error("%s while refreshing %s", util.error_msg(e), str(self))
158158
raise
159159

160160
def __str__(self) -> str:
@@ -393,7 +393,7 @@ def add_projects(self, project_list: list[str]) -> bool:
393393
log.warning("Project '%s' not found, can't be added to %s", proj, self)
394394
ok = False
395395
else:
396-
log.error("%s while adding projects to %s", util.http_error(e), str(self))
396+
log.error("%s while adding projects to %s", util.error_msg(e), str(self))
397397
raise
398398
return ok
399399

sonar/branches.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def get_object(cls, concerned_object: projects.Project, branch_name: str) -> Bra
9292
except (HTTPError, ConnectionError, RequestException) as e:
9393
if isinstance(HTTPError, e) and 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))
95+
log.critical("%s while getting branch '%s' of %s", util.error_msg(e), branch_name, str(concerned_object))
9696
raise
9797
for br in data.get("branches", []):
9898
if br["name"] == branch_name:
@@ -132,7 +132,7 @@ def refresh(self) -> Branch:
132132
except (HTTPError, ConnectionError, RequestException) as e:
133133
if isinstance(HTTPError, e) and e.response.status_code == HTTPStatus.NOT_FOUND:
134134
raise exceptions.ObjectNotFound(self.key, f"{str(self)} not found in SonarQube")
135-
log.error("%s while refreshing %s", util.http_error(e), str(self))
135+
log.error("%s while refreshing %s", util.error_msg(e), str(self))
136136
for br in data.get("branches", []):
137137
if br["name"] == self.name:
138138
self._load(br)
@@ -189,7 +189,7 @@ def delete(self) -> bool:
189189
if isinstance(e, HTTPError) and e.response.status_code == HTTPStatus.BAD_REQUEST:
190190
log.warning("Can't delete %s, it's the main branch", str(self))
191191
else:
192-
log.error("%s while deleting %s", util.http_error(e), str(self))
192+
log.error("%s while deleting %s", util.error_msg(e), str(self))
193193
return False
194194

195195
def new_code(self) -> str:
@@ -205,7 +205,7 @@ def new_code(self) -> str:
205205
except (HTTPError, ConnectionError, RequestException) as e:
206206
if isinstance(e, HTTPError) and e.response.status_code == HTTPStatus.NOT_FOUND:
207207
raise exceptions.ObjectNotFound(self.concerned_object.key, f"{str(self.concerned_object)} not found")
208-
log.error("%s while getting new code period of %s", util.http_error(e), str(self))
208+
log.error("%s while getting new code period of %s", util.error_msg(e), str(self))
209209
raise e
210210
for b in data["newCodePeriods"]:
211211
new_code = settings.new_code_to_string(b)
@@ -268,7 +268,7 @@ def rename(self, new_name):
268268
except (HTTPError, ConnectionError, RequestException) as e:
269269
if isinstance(HTTPError, e) and e.response.status_code == HTTPStatus.NOT_FOUND:
270270
raise exceptions.ObjectNotFound(self.concerned_object.key, f"str{self.concerned_object} not found")
271-
log.error("%s while renaming %s", util.http_error(e), str(self))
271+
log.error("%s while renaming %s", util.error_msg(e), str(self))
272272
raise
273273
_OBJECTS.pop(self.uuid(), None)
274274
self.name = new_name
@@ -365,7 +365,7 @@ def audit(self, audit_settings: types.ConfigSettings) -> list[Problem]:
365365
try:
366366
return self.__audit_last_analysis(audit_settings) + self.__audit_zero_loc() + self.__audit_never_analyzed()
367367
except (HTTPError, RequestException, Exception) as e:
368-
log.error("%s while auditing %s, audit skipped", util.http_error(e), str(self))
368+
log.error("%s while auditing %s, audit skipped", util.error_msg(e), str(self))
369369
else:
370370
log.debug("Branch audit disabled, skipping audit of %s", str(self))
371371
return []

sonar/devops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def create(cls, endpoint: platform.Platform, key: str, plt_type: str, url_or_wor
113113
if e.response.status_code == HTTPStatus.BAD_REQUEST and endpoint.edition() in ("community", "developer"):
114114
log.warning("Can't set DevOps platform '%s', don't you have more that 1 of that type?", key)
115115
raise exceptions.UnsupportedOperation(f"Can't set DevOps platform '{key}', don't you have more that 1 of that type?")
116-
log.error("%s while creating devops platform %s/%s/%s", util.http_error(e), key, plt_type, url_or_workspace)
116+
log.error("%s while creating devops platform %s/%s/%s", util.error_msg(e), key, plt_type, url_or_workspace)
117117
raise
118118
o = DevopsPlatform(endpoint=endpoint, key=key, platform_type=plt_type)
119119
o.refresh()

sonar/hotspots.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def search(endpoint: pf.Platform, filters: types.ApiParams = None) -> dict[str,
407407
log.warning("No hotspots found with search params %s", str(inline_filters))
408408
nbr_hotspots = 0
409409
return {}
410-
log.error("%s while searching hotspots", util.http_error(e))
410+
log.error("%s while searching hotspots", util.error_msg(e))
411411
break
412412
nbr_pages = util.nbr_pages(data)
413413
log.debug("Number of hotspots: %d - Page: %d/%d", nbr_hotspots, inline_filters["p"], nbr_pages)

sonar/issues.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ def __search_thread(queue: Queue) -> None:
733733
issue_list[i["key"]] = get_object(endpoint=endpoint, key=i["key"], data=i)
734734
log.debug("Added %d issues in threaded search page %d", len(data["issues"]), page)
735735
except (HTTPError, ConnectionError, RequestException, Exception) as e:
736-
log.error("%s while searching issues, search may be incomplete", util.http_error(e))
736+
log.error("%s while searching issues, search may be incomplete", util.error_msg(e))
737737
queue.task_done()
738738

739739

@@ -859,7 +859,7 @@ def count_by_rule(endpoint: pf.Platform, **kwargs) -> dict[str, int]:
859859
rulecount[d["val"]] = 0
860860
rulecount[d["val"]] += d["count"]
861861
except (HTTPError, Exception, RequestException) as e:
862-
log.error("%s while counting issues per rule, count may be incomplete", util.http_error(e))
862+
log.error("%s while counting issues per rule, count may be incomplete", util.error_msg(e))
863863
return rulecount
864864

865865

sonar/measures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def get(concerned_object: object, metrics_list: KeyList, **kwargs) -> dict[str,
127127
except (HTTPError, ConnectionError, RequestException) as e:
128128
if isinstance(e, HTTPError) and e.response.status_code == HTTPStatus.NOT_FOUND:
129129
raise exceptions.ObjectNotFound(concerned_object.key, f"{str(concerned_object)} not found")
130-
log.error("%s while getting measures %s of %s", util.http_error(e), str(metrics_list), str(concerned_object))
130+
log.error("%s while getting measures %s of %s", util.error_msg(e), str(metrics_list), str(concerned_object))
131131
raise e
132132
m_dict = {m: None for m in metrics_list}
133133
for m in data["component"]["measures"]:
@@ -158,7 +158,7 @@ def get_history(concerned_object: object, metrics_list: KeyList, **kwargs) -> li
158158
except (HTTPError, ConnectionError, RequestException) as e:
159159
if isinstance(e, HTTPError) and e.response.status_code == HTTPStatus.NOT_FOUND:
160160
raise exceptions.ObjectNotFound(concerned_object.key, f"{str(concerned_object)} not found")
161-
log.error("%s while getting measures %s history of %s", util.http_error(e), str(metrics_list), str(concerned_object))
161+
log.error("%s while getting measures %s history of %s", util.error_msg(e), str(metrics_list), str(concerned_object))
162162
raise e
163163
res_list = []
164164
# last_metric, last_date = "", ""

0 commit comments

Comments
 (0)