From 6f9bc0e86d67475be486db6a18b56e8a181ec19e 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 ++-- .../capellacollab/projects/toolmodels/injectables.py | 4 ++-- .../projects/toolmodels/modelsources/git/routes.py | 5 +++-- backend/capellacollab/projects/toolmodels/routes.py | 11 ++++++----- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/backend/capellacollab/__main__.py b/backend/capellacollab/__main__.py index 224fe7caf..69ccd5fb8 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 dcc5112a5..b0457439e 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 9f01e8663..bd0511d98 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 name '{model.name}' was not found.", }, ) diff --git a/backend/capellacollab/projects/toolmodels/backups/runs/injectables.py b/backend/capellacollab/projects/toolmodels/backups/runs/injectables.py index 087442acb..9cfe4ca7d 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 4bc86610d..bcfb49481 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.name}' 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 bb9ab2af9..7e524c7b0 100644 --- a/backend/capellacollab/projects/toolmodels/modelsources/git/routes.py +++ b/backend/capellacollab/projects/toolmodels/modelsources/git/routes.py @@ -45,8 +45,9 @@ 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": "We couldn't find a matching Git instance. Please that your system administrator allows the given URL.", + "technical": f"There is no Git instance, which has a prefix of the path '{path}' as URL.", }, ) diff --git a/backend/capellacollab/projects/toolmodels/routes.py b/backend/capellacollab/projects/toolmodels/routes.py index 9c5942c77..32befc9ff 100644 --- a/backend/capellacollab/projects/toolmodels/routes.py +++ b/backend/capellacollab/projects/toolmodels/routes.py @@ -97,8 +97,8 @@ def create_new_tool_model( raise fastapi.HTTPException( status_code=status.HTTP_409_CONFLICT, detail={ - "reason": "A model with a similar name already exists.", - "technical": "Slug already used", + "reason": f"A model with the name {new_model.name} already exists.", + "technical": f"The slug '{slugify.slugify(new_model.name)}' is already used", }, ) @@ -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}'." }, )