Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 1cb15ab

Browse files
authored
Catch WorkspaceCrudError on delete (#665)
This catches this error and displays it in a user-friendly fashion. Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
1 parent da7770a commit 1cb15ab

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/codegate/api/v1.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ async def delete_workspace(workspace_name: str):
8686
_ = await wscrud.soft_delete_workspace(workspace_name)
8787
except crud.WorkspaceDoesNotExistError:
8888
raise HTTPException(status_code=404, detail="Workspace does not exist")
89+
except crud.WorkspaceCrudError as e:
90+
raise HTTPException(status_code=400, detail=str(e))
8991
except Exception:
9092
raise HTTPException(status_code=500, detail="Internal server error")
9193

src/codegate/pipeline/cli/commands.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ async def _remove_workspace(self, flags: Dict[str, str], args: List[str]) -> str
227227
await self.workspace_crud.soft_delete_workspace(workspace_name)
228228
except crud.WorkspaceDoesNotExistError:
229229
return f"Workspace **{workspace_name}** does not exist"
230+
except crud.WorkspaceCrudError as e:
231+
return str(e)
230232
except Exception:
231233
return "An error occurred while removing the workspace"
232234
return f"Workspace **{workspace_name}** has been removed"

0 commit comments

Comments
 (0)