You've already forked agentic-coding-workflow
feat(workspace): migration 0003 + errs codes for workspace/worktree/git
This commit is contained in:
@@ -32,6 +32,18 @@ const (
|
||||
CodeProjectSlugTaken Code = "project_slug_taken"
|
||||
CodeProjectArchived Code = "project_archived"
|
||||
CodeRequirementClosed Code = "requirement_closed"
|
||||
|
||||
// Workspace 模块细粒度 code
|
||||
CodeWorkspaceSlugTaken Code = "workspace_slug_taken"
|
||||
CodeWorkspaceCloneFailed Code = "workspace_clone_failed"
|
||||
CodeWorkspaceSyncInProgress Code = "workspace_sync_in_progress"
|
||||
CodeWorkspaceRemoteInvalid Code = "workspace_remote_invalid"
|
||||
CodeWorktreeBranchConflict Code = "worktree_branch_conflict"
|
||||
CodeWorktreeAlreadyActive Code = "worktree_already_active"
|
||||
CodeWorktreeNotHeldByCaller Code = "worktree_not_held_by_caller"
|
||||
CodeWorktreePathInvalid Code = "worktree_path_invalid"
|
||||
CodeGitCredentialInvalid Code = "git_credential_invalid"
|
||||
CodeGitCmdFailed Code = "git_cmd_failed"
|
||||
)
|
||||
|
||||
// AppError is the application's structured error type. It carries a stable
|
||||
@@ -103,7 +115,9 @@ func HTTPStatus(code Code) int {
|
||||
case CodeNotFound:
|
||||
return http.StatusNotFound
|
||||
case CodeConflict,
|
||||
CodeProjectSlugTaken, CodeProjectArchived, CodeRequirementClosed:
|
||||
CodeProjectSlugTaken, CodeProjectArchived, CodeRequirementClosed,
|
||||
CodeWorkspaceSlugTaken, CodeWorkspaceSyncInProgress,
|
||||
CodeWorktreeBranchConflict, CodeWorktreeAlreadyActive:
|
||||
return http.StatusConflict
|
||||
case CodeRateLimited:
|
||||
return http.StatusTooManyRequests
|
||||
@@ -111,6 +125,12 @@ func HTTPStatus(code Code) int {
|
||||
return http.StatusBadGateway
|
||||
case CodeUnavailable:
|
||||
return http.StatusServiceUnavailable
|
||||
case CodeWorkspaceCloneFailed, CodeGitCmdFailed:
|
||||
return http.StatusBadGateway
|
||||
case CodeWorkspaceRemoteInvalid, CodeWorktreePathInvalid, CodeGitCredentialInvalid:
|
||||
return http.StatusBadRequest
|
||||
case CodeWorktreeNotHeldByCaller:
|
||||
return http.StatusForbidden
|
||||
default:
|
||||
return http.StatusInternalServerError
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user