Skip to content

Commit

Permalink
raise more specific exception msg
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle committed Jan 31, 2024
1 parent d606ac4 commit 5a36118
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions antarest/study/web/raw_studies_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from starlette.responses import FileResponse, JSONResponse, PlainTextResponse, Response, StreamingResponse

from antarest.core.config import Config
from antarest.core.filetransfer.model import FileDownloadNotFound
from antarest.core.jwt import JWTUser
from antarest.core.model import SUB_JSON
from antarest.core.requests import RequestParameters
Expand Down Expand Up @@ -282,11 +283,17 @@ def get_matrix(
try:
_create_matrix_files(df_matrix, header, index, format, export_path)
study_service.file_transfer_manager.set_ready(export_id, use_notification=False)
except Exception as e:
except ValueError as e:
study_service.file_transfer_manager.fail(export_id, str(e))
raise HTTPException(
status_code=http.HTTPStatus.UNPROCESSABLE_ENTITY,
detail=f"Could not download matrix at path {path}: {str(e)}",
detail=f"The Excel file {export_path} already exists and cannot be replaced due to Excel policy :{str(e)}",
) from e
except FileDownloadNotFound as e:
study_service.file_transfer_manager.fail(export_id, str(e))
raise HTTPException(
status_code=http.HTTPStatus.UNPROCESSABLE_ENTITY,
detail=f"The file download does not exist in database :{str(e)}",
) from e

return FileResponse(
Expand Down

0 comments on commit 5a36118

Please sign in to comment.