Skip to content

Commit 00a51fc

Browse files
committed
Catch all exceptions in project export
1 parent d0c8a7b commit 00a51fc

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

sonar/projects.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -993,13 +993,10 @@ def export(self, export_settings: types.ConfigSettings, settings_list: dict[str,
993993
:return: All project configuration settings
994994
:rtype: dict
995995
"""
996-
997-
remove_useless = lambda d, useless: {k: v for k, v in d if k not in useless}
998-
999996
log.info("Exporting %s", str(self))
997+
json_data = self._json.copy()
998+
json_data.update({"key": self.key, "name": self.name})
1000999
try:
1001-
json_data = self._json.copy()
1002-
json_data.update({"key": self.key, "name": self.name})
10031000
json_data["binding"] = self.__export_get_binding()
10041001
nc = self.new_code()
10051002
if nc != "":
@@ -1046,14 +1043,17 @@ def export(self, export_settings: types.ConfigSettings, settings_list: dict[str,
10461043
json_data.update(s.to_json())
10471044
except HTTPError as e:
10481045
if e.response.status_code == HTTPStatus.FORBIDDEN:
1049-
log.critical("Insufficient privileges to access %s, export of this project skipped", str(self))
1050-
json_data = {"error": "Insufficient permissions while extracting project"}
1046+
log.critical("Insufficient privileges to access %s, export of this project interrupted", str(self))
1047+
json_data["error"] = f"Insufficient permissions while exporting project, export interrupted"
10511048
else:
1052-
log.critical("HTTP error %s while exporting %s, export of this project skipped", str(e), str(self))
1053-
json_data = {"error": f"HTTP error {str(e)} while extracting project"}
1049+
log.critical("HTTP error %s while exporting %s, export of this project interrupted", str(e), str(self))
1050+
json_data["error"] = f"HTTP error {str(e)} while extracting project"
10541051
except ConnectionError as e:
1055-
log.critical("Connecting error %s while extracting %s, extract of this project skipped", str(self), str(e))
1056-
json_data = {"error": f"Connection error {str(e)} while extracting prooject"}
1052+
log.critical("Connecting error %s while exporting %s, export of this project interrupted", str(self), str(e))
1053+
json_data["error"] = f"Connection error {str(e)} while extracting project, export interrupted"
1054+
except Exception as e:
1055+
log.critical("Connecting error %s while exporting %s, export of this project interrupted", str(self), str(e))
1056+
json_data["error"] = f"Exception {str(e)} while exporting project, export interrupted"
10571057
log.info("Exporting %s done", str(self))
10581058
return util.remove_nones(json_data)
10591059

0 commit comments

Comments
 (0)