Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Optimize some error messages #1321

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/capellacollab/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

Expand Down
4 changes: 2 additions & 2 deletions backend/capellacollab/projects/injectables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
},
)
4 changes: 2 additions & 2 deletions backend/capellacollab/projects/toolmodels/injectables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
},
)

Expand Down
11 changes: 6 additions & 5 deletions backend/capellacollab/projects/toolmodels/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
)

Expand Down Expand Up @@ -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.",
MoritzWeber0 marked this conversation as resolved.
Show resolved Hide resolved
"technical": "Slug already used",
},
)

Expand All @@ -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}'."
},
)

Expand All @@ -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}'."
},
)

Expand Down
Loading