Skip to content

Commit

Permalink
fix: status code issue (#1400)
Browse files Browse the repository at this point in the history
Signed-off-by: Rohan Sharma <[email protected]>
  • Loading branch information
RS-labhub authored Dec 2, 2024
1 parent 3f0a315 commit 382606c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/api/controllers/workspace/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"

"github.com/daytonaio/daytona/pkg/server"
"github.com/daytonaio/daytona/pkg/server/workspaces"
"github.com/daytonaio/daytona/pkg/server/workspaces/dto"
"github.com/gin-gonic/gin"
)
Expand Down Expand Up @@ -35,6 +36,10 @@ func CreateWorkspace(ctx *gin.Context) {

w, err := server.WorkspaceService.CreateWorkspace(ctx.Request.Context(), createWorkspaceReq)
if err != nil {
if workspaces.IsWorkspaceAlreadyExists(err) {
ctx.AbortWithError(http.StatusConflict, fmt.Errorf("workspace already exists: %w", err))
return
}
ctx.AbortWithError(http.StatusInternalServerError, fmt.Errorf("failed to create workspace: %w", err))
return
}
Expand Down

0 comments on commit 382606c

Please sign in to comment.