From 57d7a66e3e0a9834fb45b3931614dc7ef2c9c9f9 Mon Sep 17 00:00:00 2001 From: MoritzWeber Date: Mon, 5 Feb 2024 18:09:25 +0100 Subject: [PATCH] refactor: Optimize some error messages Make them clearer and easier to understand. --- backend/capellacollab/__main__.py | 2 +- backend/capellacollab/projects/injectables.py | 4 ++-- .../projects/toolmodels/backups/injectables.py | 2 +- .../projects/toolmodels/backups/runs/injectables.py | 4 ++-- backend/capellacollab/projects/toolmodels/injectables.py | 4 ++-- .../projects/toolmodels/modelsources/git/routes.py | 4 ++-- backend/capellacollab/projects/toolmodels/routes.py | 7 ++++--- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/backend/capellacollab/__main__.py b/backend/capellacollab/__main__.py index 224fe7caf0..69ccd5fb8d 100644 --- a/backend/capellacollab/__main__.py +++ b/backend/capellacollab/__main__.py @@ -128,7 +128,7 @@ async def handle_exceptions(request: fastapi.Request, exc: Exception): return response -@app.get("/healthcheck", tags=["Healthcheck"]) +@app.get("/healthcheck", tags=["Healthcheck"], include_in_schema=False) async def healthcheck(): return {"status": "alive"} diff --git a/backend/capellacollab/projects/injectables.py b/backend/capellacollab/projects/injectables.py index dcc5112a56..b0457439e2 100644 --- a/backend/capellacollab/projects/injectables.py +++ b/backend/capellacollab/projects/injectables.py @@ -18,8 +18,8 @@ def get_existing_project( raise fastapi.HTTPException( status_code=status.HTTP_404_NOT_FOUND, detail={ - "reason": f"The project having the name {project_slug} was not found.", - "technical": f"No project with {project_slug} found.", + "reason": f"The project with the slug '{project_slug}' was not found.", + "technical": f"No project with slug '{project_slug}' found.", }, ) return project diff --git a/backend/capellacollab/projects/toolmodels/backups/injectables.py b/backend/capellacollab/projects/toolmodels/backups/injectables.py index 9f01e8663a..534f3352ee 100644 --- a/backend/capellacollab/projects/toolmodels/backups/injectables.py +++ b/backend/capellacollab/projects/toolmodels/backups/injectables.py @@ -27,6 +27,6 @@ def get_existing_pipeline( raise fastapi.HTTPException( status_code=status.HTTP_404_NOT_FOUND, detail={ - "reason": f"The pipeline with the id {pipeline_id} of the model with th id {model.id} was not found.", + "reason": f"The pipeline with the ID {pipeline_id} of the model with the slug '{model.slug}' was not found.", }, ) diff --git a/backend/capellacollab/projects/toolmodels/backups/runs/injectables.py b/backend/capellacollab/projects/toolmodels/backups/runs/injectables.py index 087442acb2..9cfe4ca7da 100644 --- a/backend/capellacollab/projects/toolmodels/backups/runs/injectables.py +++ b/backend/capellacollab/projects/toolmodels/backups/runs/injectables.py @@ -26,13 +26,13 @@ def get_existing_pipeline_run( raise fastapi.HTTPException( status_code=status.HTTP_403_FORBIDDEN, detail={ - "reason": f"The pipeline run with the id {pipeline_run.id} does not belong to the pipeline with id {pipeline.id}.", + "reason": f"The pipeline run with the ID {pipeline_run.id} does not belong to the pipeline with ID {pipeline.id}.", }, ) return pipeline_run raise fastapi.HTTPException( status_code=status.HTTP_404_NOT_FOUND, detail={ - "reason": f"The pipeline run with the id {pipeline_run_id} was not found.", + "reason": f"The pipeline run with the ID {pipeline_run_id} was not found.", }, ) diff --git a/backend/capellacollab/projects/toolmodels/injectables.py b/backend/capellacollab/projects/toolmodels/injectables.py index 4bc86610d0..7352a403b4 100644 --- a/backend/capellacollab/projects/toolmodels/injectables.py +++ b/backend/capellacollab/projects/toolmodels/injectables.py @@ -24,8 +24,8 @@ def get_existing_capella_model( raise fastapi.HTTPException( status_code=status.HTTP_404_NOT_FOUND, detail={ - "reason": f"The model having the name {model_slug} of the project {project.slug} was not found.", - "technical": f"No model with {model_slug} found in the project {project.slug}.", + "reason": f"The model with the slug '{model_slug}' of the project '{project.slug}' was not found.", + "technical": f"No model with slug '{model_slug}' found in the project with slug '{project.slug}'.", }, ) return model diff --git a/backend/capellacollab/projects/toolmodels/modelsources/git/routes.py b/backend/capellacollab/projects/toolmodels/modelsources/git/routes.py index bb9ab2af96..5aba555085 100644 --- a/backend/capellacollab/projects/toolmodels/modelsources/git/routes.py +++ b/backend/capellacollab/projects/toolmodels/modelsources/git/routes.py @@ -45,8 +45,8 @@ def verify_path_prefix(db: orm.Session, path: str): raise fastapi.HTTPException( status_code=status.HTTP_404_NOT_FOUND, detail={ - "err_code": "no_git_instance_with_prefix_found", - "reason": "There exist no git instance having the resolved path as prefix. Please check whether you correctly selected a git instance.", + "err_code": "NO_GIT_INSTANCE_WITH_PREFIX_FOUND", + "reason": "The path validation failed. No Git instance exists with the resolved path as prefix.", }, ) diff --git a/backend/capellacollab/projects/toolmodels/routes.py b/backend/capellacollab/projects/toolmodels/routes.py index 9c5942c77a..73f0ce8fba 100644 --- a/backend/capellacollab/projects/toolmodels/routes.py +++ b/backend/capellacollab/projects/toolmodels/routes.py @@ -144,7 +144,8 @@ def patch_tool_model( raise fastapi.HTTPException( status_code=status.HTTP_409_CONFLICT, detail={ - "reason": "A model with a similar name already exists." + "reason": "A model with a similar name already exists.", + "technical": "Slug already used", }, ) @@ -157,7 +158,7 @@ def patch_tool_model( raise fastapi.HTTPException( status_code=status.HTTP_409_CONFLICT, detail={ - "reason": f"The tool having the version “{version.name}” (“{version.tool.name}”) does not match the tool of the model “{model.name}” (“{model.tool.name}”)." + "reason": f"The tool '{version.tool.name}' derived from the version '{version.name}' does not match the tool '{model.tool.name}' of the model '{model.name}'." }, ) @@ -170,7 +171,7 @@ def patch_tool_model( raise fastapi.HTTPException( status_code=status.HTTP_409_CONFLICT, detail={ - "reason": f"The tool having the nature “{nature.name}” (“{nature.tool.name}”) does not match the tool of the model “{model.name}” (“{model.tool.name}”)." + "reason": f"The tool '{nature.tool.name}' derived from the nature '{nature.name}' does not match the tool '{model.tool.name}' of the model '{model.name}'." }, )