diff --git a/src/antares/craft/exceptions/exceptions.py b/src/antares/craft/exceptions/exceptions.py index 554b4882..a6e458cb 100644 --- a/src/antares/craft/exceptions/exceptions.py +++ b/src/antares/craft/exceptions/exceptions.py @@ -301,8 +301,8 @@ def __init__(self, area_name: str, cluster_name: str, matrix_name: str, message: class ThermalMatrixUpdateError(Exception): - def __init__(self, area_name: str, cluster_name: str, message: str) -> None: - self.message = f"Could not upload matrix for cluster {cluster_name} inside area {area_name}: " + message + def __init__(self, area_name: str, cluster_name: str, matrix_name: str, message: str) -> None: + self.message = f"Could not upload {matrix_name} for cluster {cluster_name} inside area {area_name}: " + message super().__init__(self.message) diff --git a/src/antares/craft/service/api_services/services/thermal.py b/src/antares/craft/service/api_services/services/thermal.py index bb173634..e3e296b8 100644 --- a/src/antares/craft/service/api_services/services/thermal.py +++ b/src/antares/craft/service/api_services/services/thermal.py @@ -82,7 +82,9 @@ def update_thermal_matrix( try: upload_series(self._base_url, self.study_id, self._wrapper, matrix, path.as_posix()) except APIError as e: - raise ThermalMatrixUpdateError(thermal_cluster.area_id, thermal_cluster.name, e.message) from e + raise ThermalMatrixUpdateError( + thermal_cluster.area_id, thermal_cluster.name, ts_name.value, e.message + ) from e @override def get_thermal_matrix(self, thermal_cluster: ThermalCluster, ts_name: ThermalClusterMatrixName) -> pd.DataFrame: diff --git a/tests/antares/services/api_services/test_thermal_api.py b/tests/antares/services/api_services/test_thermal_api.py index 71dbab28..f82472db 100644 --- a/tests/antares/services/api_services/test_thermal_api.py +++ b/tests/antares/services/api_services/test_thermal_api.py @@ -178,7 +178,7 @@ def test_update_prepro_data_fail(self): mocker.post(url, json={"description": self.antares_web_description_msg}, status_code=404) with pytest.raises( ThermalMatrixUpdateError, - match=f"Could not upload matrix for cluster {self.thermal.name} inside area {self.area.id}: " + match=f"Could not upload data for cluster {self.thermal.name} inside area {self.area.id}: " + self.antares_web_description_msg, ): self.thermal.update_prepro_data_matrix(self.matrix) @@ -227,7 +227,7 @@ def test_update_prepro_modulation_fail(self): mocker.post(url, json={"description": self.antares_web_description_msg}, status_code=404) with pytest.raises( ThermalMatrixUpdateError, - match=f"Could not upload matrix for cluster {self.thermal.name} inside area {self.area.id}: " + match=f"Could not upload modulation for cluster {self.thermal.name} inside area {self.area.id}: " + self.antares_web_description_msg, ): self.thermal.update_prepro_modulation_matrix(self.matrix) @@ -276,7 +276,7 @@ def test_update_series_fail(self): mocker.post(url, json={"description": self.antares_web_description_msg}, status_code=404) with pytest.raises( ThermalMatrixUpdateError, - match=f"Could not upload matrix for cluster {self.thermal.name} inside area {self.area.id}: " + match=f"Could not upload series for cluster {self.thermal.name} inside area {self.area.id}: " + self.antares_web_description_msg, ): self.thermal.update_series_matrix(self.matrix) @@ -325,7 +325,7 @@ def test_update_co2_cost_fail(self): mocker.post(url, json={"description": self.antares_web_description_msg}, status_code=404) with pytest.raises( ThermalMatrixUpdateError, - match=f"Could not upload matrix for cluster {self.thermal.name} inside area {self.area.id}: " + match=f"Could not upload CO2Cost for cluster {self.thermal.name} inside area {self.area.id}: " + self.antares_web_description_msg, ): self.thermal.update_co2_cost_matrix(self.matrix) @@ -374,7 +374,7 @@ def test_update_fuel_cost_fail(self): mocker.post(url, json={"description": self.antares_web_description_msg}, status_code=404) with pytest.raises( ThermalMatrixUpdateError, - match=f"Could not upload matrix for cluster {self.thermal.name} inside area {self.area.id}: " + match=f"Could not upload fuelCost for cluster {self.thermal.name} inside area {self.area.id}: " + self.antares_web_description_msg, ): self.thermal.update_fuel_cost_matrix(self.matrix)