Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
refactor: use constant errors to reduce duplication (#964)
Kyle Mendellc7a4bdcfb273
diff --git a/backend/internal/api/app_images_handler.go b/backend/internal/api/app_images_handler.goindex bfc9c6b71..70ab0fd73 100644--- a/backend/internal/api/app_images_handler.go+++ b/backend/internal/api/app_images_handler.go@@ -1,10 +1,12 @@package apiimport (+ "net/http""strconv""time""github.com/gin-gonic/gin"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/services"apphttp "github.com/ofkm/arcane-backend/internal/utils/http")@@ -44,7 +46,7 @@ func (c *ApplicationImagesHandler) getDefaultProfile(ctx *gin.Context) {func (c *ApplicationImagesHandler) getImage(ctx *gin.Context, name string) {imageData, mimeType, err := c.appImagesService.GetImage(name)if err != nil {- _ = ctx.Error(err)+ ctx.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.ImageRetrievalError{Err: err}).Error()}})return}diff --git a/backend/internal/api/auth_handler.go b/backend/internal/api/auth_handler.goindex fe9008569..a0e27bdeb 100644--- a/backend/internal/api/auth_handler.go+++ b/backend/internal/api/auth_handler.go@@ -6,6 +6,7 @@ import ("time""github.com/gin-gonic/gin"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware""github.com/ofkm/arcane-backend/internal/services"@@ -34,17 +35,17 @@ func NewAuthHandler(group *gin.RouterGroup, userService *services.UserService, afunc (h *AuthHandler) Login(c *gin.Context) {var req dto.LoginRequestif err := c.ShouldBindJSON(&req); err != nil {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": "Invalid request format"}})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()}})return}localAuthEnabled, err := h.authService.IsLocalAuthEnabled(c.Request.Context())if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": "Failed to check authentication settings"}})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.AuthSettingsCheckError{Err: err}).Error()}})return}if !localAuthEnabled {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": "Local authentication is disabled"}})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": (&common.LocalAuthDisabledError{}).Error()}})return}@@ -55,13 +56,13 @@ func (h *AuthHandler) Login(c *gin.Context) {switch {case errors.Is(err, services.ErrInvalidCredentials):statusCode = http.StatusUnauthorized- errorMsg = "Invalid username or password"+ errorMsg = (&common.InvalidCredentialsError{}).Error()case errors.Is(err, services.ErrLocalAuthDisabled):statusCode = http.StatusBadRequest- errorMsg = "Local authentication is disabled"+ errorMsg = (&common.LocalAuthDisabledError{}).Error()default:statusCode = http.StatusInternalServerError- errorMsg = "Authentication failed"+ errorMsg = (&common.AuthFailedError{Err: err}).Error()}c.JSON(statusCode, gin.H{"success": false, "data": gin.H{"error": errorMsg}})return@@ -78,7 +79,7 @@ func (h *AuthHandler) Login(c *gin.Context) {var out dto.UserResponseDtoif mapErr := dto.MapStruct(user, &out); mapErr != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": "Failed to map user"}})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.UserMappingError{Err: mapErr}).Error()}})return}@@ -102,19 +103,19 @@ func (h *AuthHandler) Logout(c *gin.Context) {func (h *AuthHandler) GetCurrentUser(c *gin.Context) {userID, exists := middleware.GetCurrentUserID(c)if !exists {- c.JSON(http.StatusUnauthorized, gin.H{"success": false, "data": gin.H{"error": "Not authenticated"}})+ c.JSON(http.StatusUnauthorized, gin.H{"success": false, "data": gin.H{"error": (&common.NotAuthenticatedError{}).Error()}})return}user, err := h.userService.GetUser(c.Request.Context(), userID)if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": "Failed to get user information"}})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.UserRetrievalError{Err: err}).Error()}})return}var out dto.UserResponseDtoif mapErr := dto.MapStruct(user, &out); mapErr != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": "Failed to map user"}})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.UserMappingError{Err: mapErr}).Error()}})return}@@ -124,7 +125,7 @@ func (h *AuthHandler) GetCurrentUser(c *gin.Context) {func (h *AuthHandler) RefreshToken(c *gin.Context) {var req dto.RefreshRequestif err := c.ShouldBindJSON(&req); err != nil {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": "Invalid request format"}})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()}})return}@@ -135,10 +136,10 @@ func (h *AuthHandler) RefreshToken(c *gin.Context) {switch {case errors.Is(err, services.ErrInvalidToken), errors.Is(err, services.ErrExpiredToken):statusCode = http.StatusUnauthorized- errorMsg = "Invalid or expired refresh token"+ errorMsg = (&common.InvalidTokenError{}).Error()default:statusCode = http.StatusInternalServerError- errorMsg = "Failed to refresh token"+ errorMsg = (&common.TokenRefreshError{Err: err}).Error()}c.JSON(statusCode, gin.H{"success": false, "data": gin.H{"error": errorMsg}})return@@ -171,12 +172,12 @@ func (h *AuthHandler) ChangePassword(c *gin.Context) {var req dto.PasswordChangeRequestif err := c.ShouldBindJSON(&req); err != nil {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": "Invalid request format"}})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()}})return}if req.CurrentPassword == "" {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": "Current password is required"}})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": (&common.PasswordRequiredError{}).Error()}})return}@@ -187,10 +188,10 @@ func (h *AuthHandler) ChangePassword(c *gin.Context) {switch {case errors.Is(err, services.ErrInvalidCredentials):statusCode = http.StatusUnauthorized- errorMsg = "Current password is incorrect"+ errorMsg = (&common.IncorrectPasswordError{}).Error()default:statusCode = http.StatusInternalServerError- errorMsg = "Failed to change password"+ errorMsg = (&common.PasswordChangeError{Err: err}).Error()}c.JSON(statusCode, gin.H{"success": false, "data": gin.H{"error": errorMsg}})returndiff --git a/backend/internal/api/container_handler.go b/backend/internal/api/container_handler.goindex 884adf1a8..5d9ebc162 100644--- a/backend/internal/api/container_handler.go+++ b/backend/internal/api/container_handler.go@@ -17,6 +17,7 @@ import ("github.com/docker/go-connections/nat""github.com/gin-gonic/gin""github.com/gorilla/websocket"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/config""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware"@@ -155,7 +156,7 @@ func (h *ContainerHandler) GetLogsWS(c *gin.Context) {containerID = c.Param("id")}if strings.TrimSpace(containerID) == "" {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": "Container ID is required"}})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": (&common.ContainerIDRequiredError{}).Error()}})return}@@ -183,7 +184,7 @@ func (h *ContainerHandler) GetLogsWS(c *gin.Context) {func (h *ContainerHandler) GetExecWS(c *gin.Context) {containerID := c.Param("containerId")if strings.TrimSpace(containerID) == "" {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": "Container ID is required"}})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": (&common.ContainerIDRequiredError{}).Error()}})return}@@ -191,7 +192,7 @@ func (h *ContainerHandler) GetExecWS(c *gin.Context) {conn, err := h.containerWSUpgrader.Upgrade(c.Writer, c.Request, nil)if err != nil {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": "Failed to upgrade connection: " + err.Error()}})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": (&common.WebSocketUpgradeError{Err: err}).Error()}})return}defer conn.Close()@@ -201,13 +202,13 @@ func (h *ContainerHandler) GetExecWS(c *gin.Context) {execID, err := h.containerService.CreateExec(ctx, containerID, []string{shell})if err != nil {- _ = conn.WriteMessage(websocket.TextMessage, []byte(fmt.Sprintf("Error creating exec: %v\r\n", err)))+ _ = conn.WriteMessage(websocket.TextMessage, []byte((&common.ExecCreationError{Err: err}).Error()+"\r\n"))return}stdin, stdout, err := h.containerService.AttachExec(ctx, execID)if err != nil {- _ = conn.WriteMessage(websocket.TextMessage, []byte(fmt.Sprintf("Error attaching to exec: %v\r\n", err)))+ _ = conn.WriteMessage(websocket.TextMessage, []byte((&common.ExecAttachError{Err: err}).Error()+"\r\n"))return}defer func() {@@ -310,7 +311,7 @@ func (h *ContainerHandler) List(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to list containers: " + err.Error()},+ "data": gin.H{"error": (&common.ContainerListError{Err: err}).Error()},})return}@@ -335,7 +336,7 @@ func (h *ContainerHandler) GetByID(c *gin.Context) {if err != nil {c.JSON(http.StatusNotFound, gin.H{"success": false,- "data": gin.H{"error": err.Error()},+ "data": gin.H{"error": (&common.ContainerRetrievalError{Err: err}).Error()},})return}@@ -358,7 +359,7 @@ func (h *ContainerHandler) Start(c *gin.Context) {if err := h.containerService.StartContainer(c.Request.Context(), id, *currentUser); err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": err.Error()},+ "data": gin.H{"error": (&common.ContainerStartError{Err: err}).Error()},})return}@@ -379,7 +380,7 @@ func (h *ContainerHandler) Stop(c *gin.Context) {if err := h.containerService.StopContainer(c.Request.Context(), id, *currentUser); err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": err.Error()},+ "data": gin.H{"error": (&common.ContainerStopError{Err: err}).Error()},})return}@@ -400,7 +401,7 @@ func (h *ContainerHandler) Restart(c *gin.Context) {if err := h.containerService.RestartContainer(c.Request.Context(), id, *currentUser); err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": err.Error()},+ "data": gin.H{"error": (&common.ContainerRestartError{Err: err}).Error()},})return}@@ -423,7 +424,7 @@ func (h *ContainerHandler) Delete(c *gin.Context) {if err := h.containerService.DeleteContainer(c.Request.Context(), id, force, removeVolumes, *currentUser); err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": err.Error()},+ "data": gin.H{"error": (&common.ContainerDeleteError{Err: err}).Error()},})return}@@ -439,7 +440,7 @@ func (h *ContainerHandler) GetContainerStatusCounts(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to get container counts: " + err.Error()},+ "data": gin.H{"error": (&common.ContainerStatusCountsError{Err: err}).Error()},})return}@@ -461,7 +462,7 @@ func (h *ContainerHandler) Create(c *gin.Context) {if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Invalid request format: " + err.Error()},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -485,7 +486,7 @@ func (h *ContainerHandler) Create(c *gin.Context) {if err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Invalid port format: " + err.Error()},+ "data": gin.H{"error": (&common.InvalidPortFormatError{Err: err}).Error()},})return}@@ -540,7 +541,7 @@ func (h *ContainerHandler) Create(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": err.Error()},+ "data": gin.H{"error": (&common.ContainerCreationError{Err: err}).Error()},})return}@@ -624,7 +625,7 @@ func (h *ContainerHandler) GetStatsWS(c *gin.Context) {containerID = c.Param("id")}if strings.TrimSpace(containerID) == "" {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": "Container ID is required"}})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": (&common.ContainerIDRequiredError{}).Error()}})return}diff --git a/backend/internal/api/container_registry_handler.go b/backend/internal/api/container_registry_handler.goindex 2be3d0de8..d458083a4 100644--- a/backend/internal/api/container_registry_handler.go+++ b/backend/internal/api/container_registry_handler.go@@ -6,6 +6,7 @@ import ("net/http""github.com/gin-gonic/gin"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware""github.com/ofkm/arcane-backend/internal/models"@@ -43,7 +44,7 @@ func (h *ContainerRegistryHandler) GetRegistries(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to list registries: " + err.Error()},+ "data": gin.H{"error": (&common.RegistryListError{Err: err}).Error()},})return}@@ -63,7 +64,7 @@ func (h *ContainerRegistryHandler) GetRegistry(c *gin.Context) {apiErr := models.ToAPIError(err)c.JSON(apiErr.HTTPStatus(), gin.H{"success": false,- "data": gin.H{"error": apiErr.Message},+ "data": gin.H{"error": (&common.RegistryRetrievalError{Err: err}).Error()},})return}@@ -72,7 +73,7 @@ func (h *ContainerRegistryHandler) GetRegistry(c *gin.Context) {if mapErr != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to map registry"},+ "data": gin.H{"error": (&common.RegistryMappingError{Err: mapErr}).Error()},})return}@@ -86,10 +87,9 @@ func (h *ContainerRegistryHandler) GetRegistry(c *gin.Context) {func (h *ContainerRegistryHandler) CreateRegistry(c *gin.Context) {var req models.CreateContainerRegistryRequestif err := c.ShouldBindJSON(&req); err != nil {- apiErr := models.NewValidationError("Invalid request data", err)- c.JSON(apiErr.HTTPStatus(), gin.H{+ c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": apiErr.Message},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -99,7 +99,7 @@ func (h *ContainerRegistryHandler) CreateRegistry(c *gin.Context) {apiErr := models.ToAPIError(err)c.JSON(apiErr.HTTPStatus(), gin.H{"success": false,- "data": gin.H{"error": apiErr.Message},+ "data": gin.H{"error": (&common.RegistryCreationError{Err: err}).Error()},})return}@@ -108,7 +108,7 @@ func (h *ContainerRegistryHandler) CreateRegistry(c *gin.Context) {if mapErr != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to map registry"},+ "data": gin.H{"error": (&common.RegistryMappingError{Err: mapErr}).Error()},})return}@@ -124,10 +124,9 @@ func (h *ContainerRegistryHandler) UpdateRegistry(c *gin.Context) {var req models.UpdateContainerRegistryRequestif err := c.ShouldBindJSON(&req); err != nil {- apiErr := models.NewValidationError("Invalid request data", err)- c.JSON(apiErr.HTTPStatus(), gin.H{+ c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": apiErr.Message},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -137,7 +136,7 @@ func (h *ContainerRegistryHandler) UpdateRegistry(c *gin.Context) {apiErr := models.ToAPIError(err)c.JSON(apiErr.HTTPStatus(), gin.H{"success": false,- "data": gin.H{"error": apiErr.Message},+ "data": gin.H{"error": (&common.RegistryUpdateError{Err: err}).Error()},})return}@@ -146,7 +145,7 @@ func (h *ContainerRegistryHandler) UpdateRegistry(c *gin.Context) {if mapErr != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to map registry"},+ "data": gin.H{"error": (&common.RegistryMappingError{Err: mapErr}).Error()},})return}@@ -164,7 +163,7 @@ func (h *ContainerRegistryHandler) DeleteRegistry(c *gin.Context) {apiErr := models.ToAPIError(err)c.JSON(apiErr.HTTPStatus(), gin.H{"success": false,- "data": gin.H{"error": apiErr.Message},+ "data": gin.H{"error": (&common.RegistryDeletionError{Err: err}).Error()},})return}@@ -183,17 +182,16 @@ func (h *ContainerRegistryHandler) TestRegistry(c *gin.Context) {apiErr := models.ToAPIError(err)c.JSON(apiErr.HTTPStatus(), gin.H{"success": false,- "data": gin.H{"error": apiErr.Message},+ "data": gin.H{"error": (&common.RegistryRetrievalError{Err: err}).Error()},})return}decryptedToken, err := utils.Decrypt(registry.Token)if err != nil {- apiErr := models.NewInternalServerError("Failed to decrypt token")- c.JSON(apiErr.HTTPStatus(), gin.H{+ c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": apiErr.Message},+ "data": gin.H{"error": (&common.TokenDecryptionError{Err: err}).Error()},})return}@@ -202,7 +200,7 @@ func (h *ContainerRegistryHandler) TestRegistry(c *gin.Context) {if err != nil {c.JSON(http.StatusOK, gin.H{"success": false,- "data": gin.H{"message": err.Error()},+ "data": gin.H{"message": (&common.RegistryTestError{Err: err}).Error()},})return}@@ -216,10 +214,9 @@ func (h *ContainerRegistryHandler) TestRegistry(c *gin.Context) {func (h *ContainerRegistryHandler) SyncRegistries(c *gin.Context) {var req dto.SyncRegistriesRequestif err := c.ShouldBindJSON(&req); err != nil {- apiErr := models.NewValidationError("Invalid request data", err)- c.JSON(apiErr.HTTPStatus(), gin.H{+ c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": apiErr.Message},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -228,7 +225,7 @@ func (h *ContainerRegistryHandler) SyncRegistries(c *gin.Context) {apiErr := models.ToAPIError(err)c.JSON(apiErr.HTTPStatus(), gin.H{"success": false,- "data": gin.H{"error": apiErr.Message},+ "data": gin.H{"error": (&common.RegistrySyncError{Err: err}).Error()},})return}diff --git a/backend/internal/api/customize_handler.go b/backend/internal/api/customize_handler.goindex 62d61a1d5..ff77494ec 100644--- a/backend/internal/api/customize_handler.go+++ b/backend/internal/api/customize_handler.go@@ -5,6 +5,7 @@ import ("strings""github.com/gin-gonic/gin"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware""github.com/ofkm/arcane-backend/internal/services"@@ -31,7 +32,7 @@ func (h *CustomizeHandler) Search(c *gin.Context) {if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": dto.MessageDto{Message: "Invalid request format"},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -39,7 +40,7 @@ func (h *CustomizeHandler) Search(c *gin.Context) {if strings.TrimSpace(req.Query) == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": dto.MessageDto{Message: "Query parameter is required"},+ "data": gin.H{"error": (&common.QueryParameterRequiredError{}).Error()},})return}diff --git a/backend/internal/api/environment_handler.go b/backend/internal/api/environment_handler.goindex ed6b728f7..14c422ee1 100644--- a/backend/internal/api/environment_handler.go+++ b/backend/internal/api/environment_handler.go@@ -7,6 +7,7 @@ import ("time""github.com/gin-gonic/gin"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/config""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware"@@ -73,7 +74,7 @@ func (h *EnvironmentHandler) PairAgent(c *gin.Context) {// Persist token on the agent so it survives restartsif err := h.settingsService.SetStringSetting(c.Request.Context(), "agentToken", h.cfg.AgentToken); err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": "Failed to persist agent token"}})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.AgentTokenPersistenceError{Err: err}).Error()}})return}@@ -89,7 +90,10 @@ func (h *EnvironmentHandler) PairAgent(c *gin.Context) {func (h *EnvironmentHandler) CreateEnvironment(c *gin.Context) {var req dto.CreateEnvironmentDtoif err := c.ShouldBindJSON(&req); err != nil {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": "Invalid request format: " + err.Error()}})+ c.JSON(http.StatusBadRequest, gin.H{+ "success": false,+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},+ })return}@@ -114,7 +118,7 @@ func (h *EnvironmentHandler) CreateEnvironment(c *gin.Context) {c.JSON(http.StatusBadGateway, gin.H{"success": false,"data": gin.H{- "error": "Agent pairing failed: " + err.Error(),+ "error": (&common.AgentPairingError{Err: err}).Error(),"hint": "Ensure the agent is running and the bootstrap token matches AGENT_BOOTSTRAP_TOKEN",},})@@ -127,7 +131,7 @@ func (h *EnvironmentHandler) CreateEnvironment(c *gin.Context) {created, err := h.environmentService.CreateEnvironment(c.Request.Context(), env)if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": "Failed to create environment: " + err.Error()}})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.EnvironmentCreationError{Err: err}).Error()}})return}@@ -150,7 +154,7 @@ func (h *EnvironmentHandler) CreateEnvironment(c *gin.Context) {out, mapErr := dto.MapOne[*models.Environment, dto.EnvironmentDto](created)if mapErr != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": "Failed to map environment"}})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.EnvironmentMappingError{Err: mapErr}).Error()}})return}@@ -162,7 +166,7 @@ func (h *EnvironmentHandler) ListEnvironments(c *gin.Context) {envs, paginationResp, err := h.environmentService.ListEnvironmentsPaginated(c.Request.Context(), params)if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": "Failed to fetch environments"}})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.EnvironmentListError{Err: err}).Error()}})return}@@ -179,13 +183,13 @@ func (h *EnvironmentHandler) GetEnvironment(c *gin.Context) {environment, err := h.environmentService.GetEnvironmentByID(c.Request.Context(), environmentID)if err != nil {- c.JSON(http.StatusNotFound, gin.H{"success": false, "data": gin.H{"error": "Environment not found"}})+ c.JSON(http.StatusNotFound, gin.H{"success": false, "data": gin.H{"error": (&common.EnvironmentNotFoundError{}).Error()}})return}out, mapErr := dto.MapOne[*models.Environment, dto.EnvironmentDto](environment)if mapErr != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": "Failed to map environment"}})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.EnvironmentMappingError{Err: mapErr}).Error()}})return}@@ -202,7 +206,10 @@ func (h *EnvironmentHandler) UpdateEnvironment(c *gin.Context) {var req dto.UpdateEnvironmentDtoif err := c.ShouldBindJSON(&req); err != nil {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": "Invalid request body"}})+ c.JSON(http.StatusBadRequest, gin.H{+ "success": false,+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},+ })return}@@ -216,7 +223,7 @@ func (h *EnvironmentHandler) UpdateEnvironment(c *gin.Context) {updated, updateErr := h.environmentService.UpdateEnvironment(c.Request.Context(), environmentID, updates)if updateErr != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": "Failed to update environment"}})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.EnvironmentUpdateError{Err: updateErr}).Error()}})return}@@ -224,7 +231,7 @@ func (h *EnvironmentHandler) UpdateEnvironment(c *gin.Context) {out, mapErr := dto.MapOne[*models.Environment, dto.EnvironmentDto](updated)if mapErr != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": "Failed to map environment"}})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.EnvironmentMappingError{Err: mapErr}).Error()}})return}@@ -333,13 +340,13 @@ func (h *EnvironmentHandler) DeleteEnvironment(c *gin.Context) {// Prevent deletion of local environmentif environmentID == LOCAL_DOCKER_ENVIRONMENT_ID {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": "Cannot delete local environment"}})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": (&common.LocalEnvironmentDeletionError{}).Error()}})return}err := h.environmentService.DeleteEnvironment(c.Request.Context(), environmentID)if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": "Failed to delete environment: " + err.Error()}})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.EnvironmentDeletionError{Err: err}).Error()}})return}@@ -384,7 +391,7 @@ func (h *EnvironmentHandler) UpdateHeartbeat(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to update heartbeat",+ "error": (&common.HeartbeatUpdateError{Err: err}).Error(),})return}@@ -402,7 +409,7 @@ func (h *EnvironmentHandler) SyncRegistries(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to sync registries: " + err.Error()},+ "data": gin.H{"error": (&common.RegistrySyncError{Err: err}).Error()},})return}diff --git a/backend/internal/api/event_handler.go b/backend/internal/api/event_handler.goindex 9d2265f67..6fbb8c95c 100644--- a/backend/internal/api/event_handler.go+++ b/backend/internal/api/event_handler.go@@ -4,6 +4,7 @@ import ("net/http""github.com/gin-gonic/gin"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware""github.com/ofkm/arcane-backend/internal/services"@@ -34,7 +35,7 @@ func (h *EventHandler) ListEvents(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to list events: " + err.Error()},+ "data": gin.H{"error": (&common.EventListError{Err: err}).Error()},})return}@@ -51,7 +52,7 @@ func (h *EventHandler) GetEventsByEnvironment(c *gin.Context) {if environmentID == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Environment ID is required"},+ "data": gin.H{"error": (&common.EnvironmentIDRequiredError{}).Error()},})return}@@ -62,7 +63,7 @@ func (h *EventHandler) GetEventsByEnvironment(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to list events: " + err.Error()},+ "data": gin.H{"error": (&common.EventListError{Err: err}).Error()},})return}@@ -79,7 +80,7 @@ func (h *EventHandler) CreateEvent(c *gin.Context) {if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Invalid request body: " + err.Error()},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -88,7 +89,7 @@ func (h *EventHandler) CreateEvent(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to create event: " + err.Error()},+ "data": gin.H{"error": (&common.EventCreationError{Err: err}).Error()},})return}@@ -104,7 +105,7 @@ func (h *EventHandler) DeleteEvent(c *gin.Context) {if eventID == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Event ID is required"},+ "data": gin.H{"error": (&common.EventIDRequiredError{}).Error()},})return}@@ -112,7 +113,7 @@ func (h *EventHandler) DeleteEvent(c *gin.Context) {if err := h.eventService.DeleteEvent(c.Request.Context(), eventID); err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to delete event: " + err.Error()},+ "data": gin.H{"error": (&common.EventDeletionError{Err: err}).Error()},})return}diff --git a/backend/internal/api/image_handler.go b/backend/internal/api/image_handler.goindex af29fe0e3..731f8c230 100644--- a/backend/internal/api/image_handler.go+++ b/backend/internal/api/image_handler.go@@ -11,6 +11,7 @@ import ("strings""github.com/gin-gonic/gin"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware""github.com/ofkm/arcane-backend/internal/services"@@ -51,7 +52,7 @@ func (h *ImageHandler) List(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": dto.MessageDto{Message: "Failed to list images: " + err.Error()},+ "data": gin.H{"error": (&common.ImageListError{Err: err}).Error()},})return}@@ -74,7 +75,7 @@ func (h *ImageHandler) GetByID(c *gin.Context) {img, err := h.imageService.GetImageByID(c.Request.Context(), id)if err != nil {- c.JSON(http.StatusNotFound, gin.H{"success": false, "data": dto.MessageDto{Message: err.Error()}})+ c.JSON(http.StatusNotFound, gin.H{"success": false, "data": gin.H{"error": (&common.ImageNotFoundError{Err: err}).Error()}})return}@@ -97,29 +98,27 @@ func (h *ImageHandler) Remove(c *gin.Context) {if err := h.imageService.RemoveImage(c.Request.Context(), id, force, *currentUser); err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": dto.MessageDto{Message: err.Error()},+ "data": gin.H{"error": (&common.ImageRemovalError{Err: err}).Error()},})return}c.JSON(http.StatusOK, gin.H{"success": true,- "data": dto.MessageDto{Message: "Image removed successfully"},+ "data": gin.H{"message": "Image removed successfully"},})}func (h *ImageHandler) Pull(c *gin.Context) {ctx := c.Request.Context()var req dto.ImagePullDto-if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": dto.MessageDto{Message: "Invalid request body: " + err.Error()},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}-c.Writer.Header().Set("Content-Type", "application/x-json-stream")c.Writer.Header().Set("Cache-Control", "no-cache")c.Writer.Header().Set("Connection", "keep-alive")@@ -133,7 +132,7 @@ func (h *ImageHandler) Pull(c *gin.Context) {if err := h.imageService.PullImage(ctx, req.ImageName, c.Writer, *currentUser, req.Credentials); err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": dto.MessageDto{Message: fmt.Sprintf("Failed to pull image '%s': %s", req.ImageName, err.Error())},+ "data": gin.H{"error": (&common.ImagePullError{ImageName: req.ImageName, Err: err}).Error()},})return}@@ -160,6 +159,13 @@ func (h *ImageHandler) Prune(c *gin.Context) {}}}+ } else if c.Request.ContentLength > 0 {+ // Only return error if body was provided but invalid+ c.JSON(http.StatusBadRequest, gin.H{+ "success": false,+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},+ })+ return}slog.DebugContext(c.Request.Context(), "Image prune request", slog.Bool("dangling_only", dangling))@@ -168,7 +174,7 @@ func (h *ImageHandler) Prune(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": dto.MessageDto{Message: err.Error()},+ "data": gin.H{"error": (&common.ImagePruneError{Err: err}).Error()},})return}@@ -203,7 +209,7 @@ func (h *ImageHandler) GetImageUsageCounts(c *gin.Context) {if len(errs) > 0 {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": dto.MessageDto{Message: errors.Join(errs...).Error()},+ "data": gin.H{"error": (&common.ImageUsageCountsError{Err: errors.Join(errs...)}).Error()},})return}@@ -234,7 +240,7 @@ func (h *ImageHandler) Upload(c *gin.Context) {if err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": dto.MessageDto{Message: "Invalid multipart form: " + err.Error()},+ "data": gin.H{"error": (&common.InvalidMultipartFormError{Err: err}).Error()},})return}@@ -251,7 +257,7 @@ func (h *ImageHandler) Upload(c *gin.Context) {if errors.Is(err, io.EOF) {break}- c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": dto.MessageDto{Message: "Failed to read upload: " + err.Error()}})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": (&common.FileUploadReadError{Err: err}).Error()}})return}// Only consider file parts (have a filename)@@ -266,7 +272,7 @@ func (h *ImageHandler) Upload(c *gin.Context) {}if !found || part == nil {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": dto.MessageDto{Message: "No file uploaded"}})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": (&common.NoFileUploadedError{}).Error()}})return}defer part.Close()@@ -278,7 +284,7 @@ func (h *ImageHandler) Upload(c *gin.Context) {// We allow .tar, .tar.gz, .tgz, .tar.xzlowerName := strings.ToLower(fileName)if !strings.HasSuffix(lowerName, ".tar") && !strings.HasSuffix(lowerName, ".tar.gz") && !strings.HasSuffix(lowerName, ".tgz") && !strings.HasSuffix(lowerName, ".tar.xz") {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": dto.MessageDto{Message: "Invalid file format. Only Docker image tar archives are allowed (.tar, .tar.gz, .tgz, .tar.xz)"}})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": (&common.InvalidFileFormatError{}).Error()}})return}@@ -286,10 +292,10 @@ func (h *ImageHandler) Upload(c *gin.Context) {if err != nil {// Check if it's a size limit errorif strings.Contains(err.Error(), "exceeds maximum allowed size") {- c.JSON(http.StatusRequestEntityTooLarge, gin.H{"success": false, "data": dto.MessageDto{Message: err.Error()}})+ c.JSON(http.StatusRequestEntityTooLarge, gin.H{"success": false, "data": gin.H{"error": err.Error()}})return}- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": dto.MessageDto{Message: "Failed to load image: " + err.Error()}})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.ImageLoadError{Err: err}).Error()}})return}diff --git a/backend/internal/api/image_update_handler.go b/backend/internal/api/image_update_handler.goindex e3067801c..b12610d81 100644--- a/backend/internal/api/image_update_handler.go+++ b/backend/internal/api/image_update_handler.go@@ -4,6 +4,7 @@ import ("net/http""github.com/gin-gonic/gin"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware""github.com/ofkm/arcane-backend/internal/services"@@ -33,7 +34,7 @@ func (h *ImageUpdateHandler) CheckImageUpdate(c *gin.Context) {if imageRef == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "error": "imageRef query parameter is required",+ "error": (&common.ImageRefRequiredError{}).Error(),})return}@@ -42,7 +43,7 @@ func (h *ImageUpdateHandler) CheckImageUpdate(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to check image update: " + err.Error(),+ "error": (&common.ImageUpdateCheckError{Err: err}).Error(),})return}@@ -58,7 +59,7 @@ func (h *ImageUpdateHandler) CheckImageUpdateByID(c *gin.Context) {if imageID == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "error": "imageId parameter is required",+ "error": (&common.ImageIDRequiredError{}).Error(),})return}@@ -67,7 +68,7 @@ func (h *ImageUpdateHandler) CheckImageUpdateByID(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to check image update: " + err.Error(),+ "error": (&common.ImageUpdateCheckError{Err: err}).Error(),})return}@@ -83,7 +84,7 @@ func (h *ImageUpdateHandler) CheckMultipleImages(c *gin.Context) {if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "error": "Invalid request format",+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -91,7 +92,7 @@ func (h *ImageUpdateHandler) CheckMultipleImages(c *gin.Context) {if len(req.ImageRefs) == 0 {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "error": "At least one imageRef is required",+ "error": (&common.ImageRefListRequiredError{}).Error(),})return}@@ -100,7 +101,7 @@ func (h *ImageUpdateHandler) CheckMultipleImages(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to check image updates: " + err.Error(),+ "error": (&common.BatchImageUpdateCheckError{Err: err}).Error(),})return}@@ -121,7 +122,7 @@ func (h *ImageUpdateHandler) CheckAllImages(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to check all images: " + err.Error(),+ "error": (&common.AllImageUpdateCheckError{Err: err}).Error(),})return}@@ -139,7 +140,7 @@ func (h *ImageUpdateHandler) GetUpdateSummary(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to get update summary: " + err.Error(),+ "error": (&common.UpdateSummaryError{Err: err}).Error(),})return}diff --git a/backend/internal/api/network_handler.go b/backend/internal/api/network_handler.goindex 52a827675..f56cd5995 100644--- a/backend/internal/api/network_handler.go+++ b/backend/internal/api/network_handler.go@@ -5,6 +5,7 @@ import ("github.com/docker/docker/api/types/network""github.com/gin-gonic/gin"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware""github.com/ofkm/arcane-backend/internal/services"@@ -42,7 +43,7 @@ func (h *NetworkHandler) List(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": dto.MessageDto{Message: "Failed to list networks: " + err.Error()},+ "data": gin.H{"error": (&common.NetworkListError{Err: err}).Error()},})return}@@ -67,14 +68,14 @@ func (h *NetworkHandler) GetByID(c *gin.Context) {if err != nil {c.JSON(http.StatusNotFound, gin.H{"success": false,- "data": dto.MessageDto{Message: err.Error()},+ "data": gin.H{"error": (&common.NetworkNotFoundError{Err: err}).Error()},})return}out, mapErr := dto.MapOne[network.Inspect, dto.NetworkInspectDto](*networkInspect)if mapErr != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": dto.MessageDto{Message: mapErr.Error()}})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.NetworkMappingError{Err: mapErr}).Error()}})return}@@ -93,7 +94,7 @@ func (h *NetworkHandler) Create(c *gin.Context) {if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": dto.MessageDto{Message: err.Error()},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -107,14 +108,14 @@ func (h *NetworkHandler) Create(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": dto.MessageDto{Message: err.Error()},+ "data": gin.H{"error": (&common.NetworkCreationError{Err: err}).Error()},})return}out, mapErr := dto.MapOne[network.CreateResponse, dto.NetworkCreateResponseDto](*response)if mapErr != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": dto.MessageDto{Message: mapErr.Error()}})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.NetworkMappingError{Err: mapErr}).Error()}})return}@@ -135,14 +136,14 @@ func (h *NetworkHandler) Remove(c *gin.Context) {if err := h.networkService.RemoveNetwork(c.Request.Context(), id, *currentUser); err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": dto.MessageDto{Message: err.Error()},+ "data": gin.H{"error": (&common.NetworkRemovalError{Err: err}).Error()},})return}c.JSON(http.StatusOK, gin.H{"success": true,- "data": dto.MessageDto{Message: "Network removed successfully"},+ "data": gin.H{"message": "Network removed successfully"},})}@@ -151,7 +152,7 @@ func (h *NetworkHandler) GetNetworkUsageCounts(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to get network counts: " + err.Error()},+ "data": gin.H{"error": (&common.NetworkUsageCountsError{Err: err}).Error()},})return}@@ -173,14 +174,14 @@ func (h *NetworkHandler) Prune(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": dto.MessageDto{Message: err.Error()},+ "data": gin.H{"error": (&common.NetworkPruneError{Err: err}).Error()},})return}out, mapErr := dto.MapOne[network.PruneReport, dto.NetworkPruneReportDto](*report)if mapErr != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": dto.MessageDto{Message: mapErr.Error()}})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.NetworkMappingError{Err: mapErr}).Error()}})return}diff --git a/backend/internal/api/notification_handler.go b/backend/internal/api/notification_handler.goindex a5730ee0a..e86cddcdf 100644--- a/backend/internal/api/notification_handler.go+++ b/backend/internal/api/notification_handler.go@@ -4,6 +4,7 @@ import ("net/http""github.com/gin-gonic/gin"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware""github.com/ofkm/arcane-backend/internal/models"@@ -39,7 +40,7 @@ func NewNotificationHandler(group *gin.RouterGroup, notificationService *servicefunc (h *NotificationHandler) GetAllSettings(c *gin.Context) {settings, err := h.notificationService.GetAllSettings(c.Request.Context())if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})+ c.JSON(http.StatusInternalServerError, gin.H{"error": (&common.NotificationSettingsListError{Err: err}).Error()})return}@@ -64,13 +65,13 @@ func (h *NotificationHandler) GetSettings(c *gin.Context) {switch provider {case models.NotificationProviderDiscord, models.NotificationProviderEmail:default:- c.JSON(http.StatusBadRequest, gin.H{"error": "invalid provider"})+ c.JSON(http.StatusBadRequest, gin.H{"error": (&common.InvalidNotificationProviderError{}).Error()})return}settings, err := h.notificationService.GetSettingsByProvider(c.Request.Context(), provider)if err != nil {- c.JSON(http.StatusNotFound, gin.H{"error": "Settings not found"})+ c.JSON(http.StatusNotFound, gin.H{"error": (&common.NotificationSettingsNotFoundError{}).Error()})return}@@ -87,7 +88,7 @@ func (h *NotificationHandler) GetSettings(c *gin.Context) {func (h *NotificationHandler) CreateOrUpdateSettings(c *gin.Context) {var req dto.NotificationSettingsRequestif err := c.ShouldBindJSON(&req); err != nil {- c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})+ c.JSON(http.StatusBadRequest, gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()})return}@@ -98,7 +99,7 @@ func (h *NotificationHandler) CreateOrUpdateSettings(c *gin.Context) {req.Config,)if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})+ c.JSON(http.StatusInternalServerError, gin.H{"error": (&common.NotificationSettingsUpdateError{Err: err}).Error()})return}@@ -119,12 +120,12 @@ func (h *NotificationHandler) DeleteSettings(c *gin.Context) {switch provider {case models.NotificationProviderDiscord, models.NotificationProviderEmail:default:- c.JSON(http.StatusBadRequest, gin.H{"error": "invalid provider"})+ c.JSON(http.StatusBadRequest, gin.H{"error": (&common.InvalidNotificationProviderError{}).Error()})return}if err := h.notificationService.DeleteSettings(c.Request.Context(), provider); err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})+ c.JSON(http.StatusInternalServerError, gin.H{"error": (&common.NotificationSettingsDeletionError{Err: err}).Error()})return}@@ -138,14 +139,14 @@ func (h *NotificationHandler) TestNotification(c *gin.Context) {switch provider {case models.NotificationProviderDiscord, models.NotificationProviderEmail:default:- c.JSON(http.StatusBadRequest, gin.H{"error": "invalid provider"})+ c.JSON(http.StatusBadRequest, gin.H{"error": (&common.InvalidNotificationProviderError{}).Error()})return}testType := c.DefaultQuery("type", "simple") // "simple" or "image-update"if err := h.notificationService.TestNotification(c.Request.Context(), provider, testType); err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})+ c.JSON(http.StatusInternalServerError, gin.H{"error": (&common.NotificationTestError{Err: err}).Error()})return}@@ -155,7 +156,7 @@ func (h *NotificationHandler) TestNotification(c *gin.Context) {func (h *NotificationHandler) GetAppriseSettings(c *gin.Context) {settings, err := h.appriseService.GetSettings(c.Request.Context())if err != nil {- c.JSON(http.StatusNotFound, gin.H{"error": "Apprise settings not found"})+ c.JSON(http.StatusNotFound, gin.H{"error": (&common.AppriseSettingsNotFoundError{}).Error()})return}@@ -173,7 +174,7 @@ func (h *NotificationHandler) GetAppriseSettings(c *gin.Context) {func (h *NotificationHandler) CreateOrUpdateAppriseSettings(c *gin.Context) {var req dto.AppriseSettingsRequestif err := c.ShouldBindJSON(&req); err != nil {- c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})+ c.JSON(http.StatusBadRequest, gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()})return}@@ -185,7 +186,7 @@ func (h *NotificationHandler) CreateOrUpdateAppriseSettings(c *gin.Context) {req.ContainerUpdateTag,)if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})+ c.JSON(http.StatusInternalServerError, gin.H{"error": (&common.AppriseSettingsUpdateError{Err: err}).Error()})return}@@ -202,7 +203,7 @@ func (h *NotificationHandler) CreateOrUpdateAppriseSettings(c *gin.Context) {func (h *NotificationHandler) TestAppriseNotification(c *gin.Context) {if err := h.appriseService.TestNotification(c.Request.Context()); err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})+ c.JSON(http.StatusInternalServerError, gin.H{"error": (&common.AppriseTestError{Err: err}).Error()})return}diff --git a/backend/internal/api/oidc_handler.go b/backend/internal/api/oidc_handler.goindex f59011713..67ae0aaab 100644--- a/backend/internal/api/oidc_handler.go+++ b/backend/internal/api/oidc_handler.go@@ -5,6 +5,7 @@ import ("time""github.com/gin-gonic/gin"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/services""github.com/ofkm/arcane-backend/internal/utils/cookie"@@ -33,7 +34,7 @@ func (h *OidcHandler) GetOidcStatus(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to retrieve OIDC status: " + err.Error(),+ "error": (&common.OidcStatusError{Err: err}).Error(),})return}@@ -42,25 +43,27 @@ func (h *OidcHandler) GetOidcStatus(c *gin.Context) {func (h *OidcHandler) GetOidcAuthUrl(c *gin.Context) {var req dto.OidcAuthUrlRequest-if err := c.ShouldBindJSON(&req); err != nil {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "Invalid request format"})+ c.JSON(http.StatusBadRequest, gin.H{+ "success": false,+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},+ })return}enabled, err := h.authService.IsOidcEnabled(c.Request.Context())if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "Failed to check OIDC status"})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": (&common.OidcStatusCheckError{}).Error()})return}if !enabled {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "OIDC authentication is disabled"})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": (&common.OidcDisabledError{}).Error()})return}authUrl, stateCookieValue, err := h.oidcService.GenerateAuthURL(c.Request.Context(), req.RedirectUri)if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "Failed to generate OIDC auth URL: " + err.Error()})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": (&common.OidcAuthUrlGenerationError{Err: err}).Error()})return}@@ -78,26 +81,26 @@ func (h *OidcHandler) HandleOidcCallback(c *gin.Context) {}if err := c.ShouldBindJSON(&req); err != nil {- c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request format"})+ c.JSON(http.StatusBadRequest, gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()})return}encodedStateFromCookie, err := cookie.GetOidcStateCookie(c)if err != nil {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "Missing or invalid OIDC state cookie"})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": (&common.OidcStateCookieError{}).Error()})return}cookie.ClearOidcStateCookie(c)userInfo, tokenResp, err := h.oidcService.HandleCallback(c.Request.Context(), req.Code, req.State, encodedStateFromCookie)if err != nil {- c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})+ c.JSON(http.StatusBadRequest, gin.H{"error": (&common.OidcCallbackError{Err: err}).Error()})return}user, tokenPair, err := h.authService.OidcLogin(c.Request.Context(), *userInfo, tokenResp)if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"error": "Authentication failed"})+ c.JSON(http.StatusInternalServerError, gin.H{"error": (&common.AuthFailedError{Err: err}).Error()})return}@@ -131,7 +134,7 @@ func (h *OidcHandler) GetOidcConfig(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to get OIDC configuration",+ "error": (&common.OidcConfigError{}).Error(),})return}diff --git a/backend/internal/api/playwright_handler.go b/backend/internal/api/playwright_handler.goindex c39f6bae5..0b406a07c 100644--- a/backend/internal/api/playwright_handler.go+++ b/backend/internal/api/playwright_handler.go@@ -6,6 +6,7 @@ import ("net/http""github.com/gin-gonic/gin"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/services")@@ -28,7 +29,7 @@ func SetupPlaywrightRoutes(api *gin.RouterGroup, playwrightService *services.Plafunc (ph *PlaywrightHandler) SkipOnboardingHandler(c *gin.Context) {if err := ph.PlaywrightService.SkipOnboarding(c.Request.Context()); err != nil {- _ = c.Error(err)+ c.JSON(http.StatusInternalServerError, gin.H{"error": (&common.SkipOnboardingError{Err: err}).Error()})return}@@ -37,7 +38,7 @@ func (ph *PlaywrightHandler) SkipOnboardingHandler(c *gin.Context) {func (ph *PlaywrightHandler) ResetOnboardingHandler(c *gin.Context) {if err := ph.PlaywrightService.ResetOnboarding(c.Request.Context()); err != nil {- _ = c.Error(err)+ c.JSON(http.StatusInternalServerError, gin.H{"error": (&common.ResetOnboardingError{Err: err}).Error()})return}diff --git a/backend/internal/api/project_handler.go b/backend/internal/api/project_handler.goindex fdb1e37b9..7d0064c02 100644--- a/backend/internal/api/project_handler.go+++ b/backend/internal/api/project_handler.go@@ -12,6 +12,7 @@ import ("github.com/gin-gonic/gin""github.com/gorilla/websocket"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/config""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware"@@ -81,7 +82,7 @@ func (h *ProjectHandler) ListProjects(c *gin.Context) {}c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to list projects: " + err.Error(),+ "error": (&common.ProjectListError{Err: err}).Error(),})return}@@ -102,7 +103,7 @@ func (h *ProjectHandler) DeployProject(c *gin.Context) {if projectID == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "error": "Project ID is required",+ "error": (&common.ProjectIDRequiredError{}).Error(),})return}@@ -111,7 +112,7 @@ func (h *ProjectHandler) DeployProject(c *gin.Context) {if err := h.projectService.DeployProject(c.Request.Context(), projectID, *user); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "error": err.Error(),+ "error": (&common.ProjectDeploymentError{Err: err}).Error(),})return}@@ -129,7 +130,7 @@ func (h *ProjectHandler) DownProject(c *gin.Context) {if err := h.projectService.DownProject(c.Request.Context(), projectID, *user); err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": fmt.Sprintf("Failed to bring down project: %v", err),+ "error": (&common.ProjectDownError{Err: err}).Error(),})return}@@ -143,14 +144,14 @@ func (h *ProjectHandler) DownProject(c *gin.Context) {func (h *ProjectHandler) CreateProject(c *gin.Context) {var req dto.CreateProjectDtoif err := c.ShouldBindJSON(&req); err != nil {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": err.Error()})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": (&common.InvalidRequestFormatError{Err: err}).Error()})return}user, _ := middleware.GetCurrentUser(c)proj, err := h.projectService.CreateProject(c.Request.Context(), req.Name, req.ComposeContent, req.EnvContent, *user)if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error()})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": (&common.ProjectCreationError{Err: err}).Error()})return}@@ -174,13 +175,13 @@ func (h *ProjectHandler) CreateProject(c *gin.Context) {func (h *ProjectHandler) GetProject(c *gin.Context) {projectID := c.Param("projectId")if projectID == "" {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "Project ID is required"})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": (&common.ProjectIDRequiredError{}).Error()})return}details, err := h.projectService.GetProjectDetails(c.Request.Context(), projectID)if err != nil {- c.JSON(http.StatusNotFound, gin.H{"success": false, "error": "Project not found"})+ c.JSON(http.StatusNotFound, gin.H{"success": false, "error": (&common.ProjectDetailsError{Err: err}).Error()})return}@@ -196,7 +197,7 @@ func (h *ProjectHandler) RedeployProject(c *gin.Context) {if projectID == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "error": "Project ID is required",+ "error": (&common.ProjectIDRequiredError{}).Error(),})return}@@ -205,7 +206,7 @@ func (h *ProjectHandler) RedeployProject(c *gin.Context) {if err := h.projectService.RedeployProject(c.Request.Context(), projectID, *user); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "error": err.Error(),+ "error": (&common.ProjectRedeploymentError{Err: err}).Error(),})return}@@ -220,10 +221,10 @@ func (h *ProjectHandler) DestroyProject(c *gin.Context) {projectID := c.Param("projectId")var req dto.DestroyProjectDto- if err := c.ShouldBindJSON(&req); err != nil {- req = dto.DestroyProjectDto{- RemoveFiles: false,- RemoveVolumes: false,+ if c.Request.ContentLength > 0 {+ if err := c.ShouldBindJSON(&req); err != nil {+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": (&common.InvalidRequestFormatError{Err: err}).Error()})+ return}}@@ -231,7 +232,7 @@ func (h *ProjectHandler) DestroyProject(c *gin.Context) {if err := h.projectService.DestroyProject(c.Request.Context(), projectID, req.RemoveFiles, req.RemoveVolumes, *user); err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": fmt.Sprintf("Failed to destroy project: %v", err),+ "error": (&common.ProjectDestroyError{Err: err}).Error(),})return}@@ -245,13 +246,16 @@ func (h *ProjectHandler) DestroyProject(c *gin.Context) {func (h *ProjectHandler) PullProjectImages(c *gin.Context) {projectID := c.Param("projectId")if projectID == "" {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "Project ID is required"})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": (&common.ProjectIDRequiredError{}).Error()})return}var req dto.ProjectImagePullDto- if err := c.ShouldBindJSON(&req); err != nil {- req = dto.ProjectImagePullDto{}+ if c.Request.ContentLength > 0 {+ if err := c.ShouldBindJSON(&req); err != nil {+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": (&common.InvalidRequestFormatError{Err: err}).Error()})+ return+ }}c.Writer.Header().Set("Content-Type", "application/x-json-stream")@@ -272,24 +276,24 @@ func (h *ProjectHandler) PullProjectImages(c *gin.Context) {func (h *ProjectHandler) UpdateProject(c *gin.Context) {projectID := c.Param("projectId")if projectID == "" {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "Project ID is required"})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": (&common.ProjectIDRequiredError{}).Error()})return}var req dto.UpdateProjectDtoif err := c.ShouldBindJSON(&req); err != nil {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "Invalid request format"})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": (&common.InvalidRequestFormatError{Err: err}).Error()})return}if _, err := h.projectService.UpdateProject(c.Request.Context(), projectID, req.Name, req.ComposeContent, req.EnvContent); err != nil {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": err.Error()})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": (&common.ProjectUpdateError{Err: err}).Error()})return}details, err := h.projectService.GetProjectDetails(c.Request.Context(), projectID)if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "Failed to fetch updated project details"})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": (&common.ProjectDetailsError{Err: err}).Error()})return}@@ -302,24 +306,24 @@ func (h *ProjectHandler) UpdateProject(c *gin.Context) {func (h *ProjectHandler) UpdateProjectInclude(c *gin.Context) {projectID := c.Param("projectId")if projectID == "" {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "Project ID is required"})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": (&common.ProjectIDRequiredError{}).Error()})return}var req dto.UpdateProjectIncludeDtoif err := c.ShouldBindJSON(&req); err != nil {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "Invalid request format"})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": (&common.InvalidRequestFormatError{Err: err}).Error()})return}if err := h.projectService.UpdateProjectIncludeFile(c.Request.Context(), projectID, req.RelativePath, req.Content); err != nil {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": err.Error()})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": (&common.ProjectUpdateError{Err: err}).Error()})return}details, err := h.projectService.GetProjectDetails(c.Request.Context(), projectID)if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "Failed to fetch updated project details"})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": (&common.ProjectDetailsError{Err: err}).Error()})return}@@ -332,13 +336,13 @@ func (h *ProjectHandler) UpdateProjectInclude(c *gin.Context) {func (h *ProjectHandler) RestartProject(c *gin.Context) {projectID := c.Param("projectId")if projectID == "" {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "Project ID is required"})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": (&common.ProjectIDRequiredError{}).Error()})return}user, _ := middleware.GetCurrentUser(c)if err := h.projectService.RestartProject(c.Request.Context(), projectID, *user); err != nil {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": err.Error()})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": (&common.ProjectRestartError{Err: err}).Error()})return}@@ -414,7 +418,7 @@ func (h *ProjectHandler) getOrStartProjectLogHub(projectID, format string, batchfunc (h *ProjectHandler) GetProjectLogsWS(c *gin.Context) {projectID := c.Param("projectId")if strings.TrimSpace(projectID) == "" {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "Project ID is required"})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": (&common.ProjectIDRequiredError{}).Error()})return}@@ -438,7 +442,7 @@ func (h *ProjectHandler) GetProjectStatusCounts(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to get project counts: " + err.Error()},+ "data": gin.H{"error": (&common.ProjectStatusCountsError{Err: err}).Error()},})return}diff --git a/backend/internal/api/settings_handler.go b/backend/internal/api/settings_handler.goindex 3b13d0851..a60f13a3a 100644--- a/backend/internal/api/settings_handler.go+++ b/backend/internal/api/settings_handler.go@@ -6,6 +6,7 @@ import ("strings""github.com/gin-gonic/gin"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/config""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware"@@ -41,7 +42,7 @@ func (h *SettingsHandler) Search(c *gin.Context) {if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": dto.MessageDto{Message: "Invalid request format"},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -49,7 +50,7 @@ func (h *SettingsHandler) Search(c *gin.Context) {if strings.TrimSpace(req.Query) == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": dto.MessageDto{Message: "Query parameter is required"},+ "data": gin.H{"error": (&common.QueryParameterRequiredError{}).Error()},})return}@@ -75,7 +76,7 @@ func (h *SettingsHandler) GetSettings(c *gin.Context) {_ = c.Error(err)c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": dto.MessageDto{Message: "Failed to map settings"},+ "data": gin.H{"error": (&common.SettingsMappingError{Err: err}).Error()},})return}@@ -97,7 +98,7 @@ func (h *SettingsHandler) GetPublicSettings(c *gin.Context) {_ = c.Error(err)c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": dto.MessageDto{Message: "Failed to map settings"},+ "data": gin.H{"error": (&common.SettingsMappingError{Err: err}).Error()},})return}@@ -118,7 +119,7 @@ func (h *SettingsHandler) UpdateSettings(c *gin.Context) {if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": dto.MessageDto{Message: "Invalid request format"},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -129,7 +130,7 @@ func (h *SettingsHandler) UpdateSettings(c *gin.Context) {req.AuthOidcConfig != nil {c.JSON(http.StatusForbidden, gin.H{"success": false,- "data": dto.MessageDto{Message: "Authentication settings can only be updated from the main environment"},+ "data": gin.H{"error": (&common.AuthSettingsUpdateError{}).Error()},})return}@@ -139,7 +140,7 @@ func (h *SettingsHandler) UpdateSettings(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": dto.MessageDto{Message: "Failed to update settings"},+ "data": gin.H{"error": (&common.SettingsUpdateError{Err: err}).Error()},})return}diff --git a/backend/internal/api/system_handler.go b/backend/internal/api/system_handler.goindex 91b531115..d12cda35b 100644--- a/backend/internal/api/system_handler.go+++ b/backend/internal/api/system_handler.go@@ -22,6 +22,7 @@ import ("github.com/docker/docker/api/types/image""github.com/gin-gonic/gin""github.com/gorilla/websocket"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/config""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware"@@ -143,7 +144,7 @@ func (h *SystemHandler) GetDockerInfo(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to connect to Docker: " + err.Error(),+ "error": (&common.DockerConnectionError{Err: err}).Error(),})return}@@ -153,7 +154,7 @@ func (h *SystemHandler) GetDockerInfo(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to get Docker version: " + err.Error(),+ "error": (&common.DockerVersionError{Err: err}).Error(),})return}@@ -162,7 +163,7 @@ func (h *SystemHandler) GetDockerInfo(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to get Docker info: " + err.Error(),+ "error": (&common.DockerInfoError{Err: err}).Error(),})return}@@ -171,7 +172,7 @@ func (h *SystemHandler) GetDockerInfo(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to list containers: " + err.Error(),+ "error": (&common.DockerContainerListError{Err: err}).Error(),})return}@@ -180,7 +181,7 @@ func (h *SystemHandler) GetDockerInfo(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to list images: " + err.Error(),+ "error": (&common.DockerImageListError{Err: err}).Error(),})return}@@ -248,7 +249,7 @@ func (h *SystemHandler) PruneAll(c *gin.Context) {slog.String("client_ip", c.ClientIP()))c.JSON(http.StatusBadRequest, gin.H{"success": false,- "error": "Invalid request body: " + err.Error(),+ "error": (&common.InvalidRequestFormatError{Err: err}).Error(),})return}@@ -268,7 +269,7 @@ func (h *SystemHandler) PruneAll(c *gin.Context) {slog.String("client_ip", c.ClientIP()))c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to prune resources: " + err.Error(),+ "error": (&common.SystemPruneError{Err: err}).Error(),})return}@@ -301,7 +302,7 @@ func (h *SystemHandler) StartAllContainers(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to start containers: " + err.Error(),+ "error": (&common.ContainerStartAllError{Err: err}).Error(),})return}@@ -318,7 +319,7 @@ func (h *SystemHandler) StartAllStoppedContainers(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to start stopped containers: " + err.Error(),+ "error": (&common.ContainerStartStoppedError{Err: err}).Error(),})return}@@ -357,7 +358,7 @@ func (h *SystemHandler) StopAllContainers(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to stop containers: " + err.Error(),+ "error": (&common.ContainerStopAllError{Err: err}).Error(),})return}@@ -535,7 +536,7 @@ func (h *SystemHandler) ConvertDockerRun(c *gin.Context) {if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "error": "Invalid request format: " + err.Error(),+ "error": (&common.InvalidRequestFormatError{Err: err}).Error(),})return}@@ -544,7 +545,7 @@ func (h *SystemHandler) ConvertDockerRun(c *gin.Context) {if err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "error": "Failed to parse docker run command. Please check the syntax.",+ "error": (&common.DockerRunParseError{Err: err}).Error(),"code": "BAD_REQUEST",})return@@ -554,7 +555,7 @@ func (h *SystemHandler) ConvertDockerRun(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "error": "Failed to convert to Docker Compose format.",+ "error": (&common.DockerComposeConversionError{Err: err}).Error(),"code": "CONVERSION_ERROR",})return@@ -577,7 +578,7 @@ func (h *SystemHandler) CheckUpgradeAvailable(c *gin.Context) {c.JSON(http.StatusOK, gin.H{"canUpgrade": false,"error": true,- "message": err.Error(),+ "message": (&common.UpgradeCheckError{Err: err}).Error(),})slog.Debug("System upgrade check failed", "error", err)return@@ -610,7 +611,7 @@ func (h *SystemHandler) TriggerUpgrade(c *gin.Context) {}c.JSON(statusCode, gin.H{- "error": err.Error(),+ "error": (&common.UpgradeTriggerError{Err: err}).Error(),"message": "Failed to initiate upgrade",})returndiff --git a/backend/internal/api/template_handler.go b/backend/internal/api/template_handler.goindex 8c2668096..ce0489c41 100644--- a/backend/internal/api/template_handler.go+++ b/backend/internal/api/template_handler.go@@ -5,6 +5,7 @@ import ("net/http""github.com/gin-gonic/gin"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware""github.com/ofkm/arcane-backend/internal/models"@@ -56,7 +57,7 @@ func (h *TemplateHandler) GetAllTemplatesPaginated(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to get templates: " + err.Error()},+ "data": gin.H{"error": (&common.TemplateListError{Err: err}).Error()},})return}@@ -79,7 +80,7 @@ func (h *TemplateHandler) GetAllTemplates(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to get templates: " + err.Error()},+ "data": gin.H{"error": (&common.TemplateListError{Err: err}).Error()},})return}@@ -90,7 +91,7 @@ func (h *TemplateHandler) GetAllTemplates(c *gin.Context) {} else {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to map templates: " + mapErr.Error()},+ "data": gin.H{"error": (&common.TemplateMappingError{Err: mapErr}).Error()},})return}@@ -106,7 +107,7 @@ func (h *TemplateHandler) GetTemplate(c *gin.Context) {if id == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Template ID is required"},+ "data": gin.H{"error": (&common.TemplateIDRequiredError{}).Error()},})return}@@ -114,10 +115,12 @@ func (h *TemplateHandler) GetTemplate(c *gin.Context) {template, err := h.templateService.GetTemplate(c.Request.Context(), id)if err != nil {status := http.StatusInternalServerError- msg := "Failed to get template: " + err.Error()+ var msg stringif err.Error() == "template not found" {status = http.StatusNotFound- msg = "Template not found"+ msg = (&common.TemplateNotFoundError{}).Error()+ } else {+ msg = (&common.TemplateRetrievalError{Err: err}).Error()}c.JSON(status, gin.H{"success": false,@@ -130,7 +133,7 @@ func (h *TemplateHandler) GetTemplate(c *gin.Context) {if mapErr := dto.MapStruct(template, &out); mapErr != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to map template: " + mapErr.Error()},+ "data": gin.H{"error": (&common.TemplateMappingError{Err: mapErr}).Error()},})return}@@ -146,7 +149,7 @@ func (h *TemplateHandler) GetTemplateContent(c *gin.Context) {if id == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Template ID is required"},+ "data": gin.H{"error": (&common.TemplateIDRequiredError{}).Error()},})return}@@ -155,7 +158,7 @@ func (h *TemplateHandler) GetTemplateContent(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to get template content: " + err.Error()},+ "data": gin.H{"error": (&common.TemplateContentError{Err: err}).Error()},})return}@@ -177,7 +180,7 @@ func (h *TemplateHandler) CreateTemplate(c *gin.Context) {if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Invalid request format: " + err.Error()},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -196,7 +199,7 @@ func (h *TemplateHandler) CreateTemplate(c *gin.Context) {if err := h.templateService.CreateTemplate(c.Request.Context(), template); err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to create template: " + err.Error()},+ "data": gin.H{"error": (&common.TemplateCreationError{Err: err}).Error()},})return}@@ -205,7 +208,7 @@ func (h *TemplateHandler) CreateTemplate(c *gin.Context) {if mapErr := dto.MapStruct(template, &out); mapErr != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to map template: " + mapErr.Error()},+ "data": gin.H{"error": (&common.TemplateMappingError{Err: mapErr}).Error()},})return}@@ -221,7 +224,7 @@ func (h *TemplateHandler) UpdateTemplate(c *gin.Context) {if id == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Template ID is required"},+ "data": gin.H{"error": (&common.TemplateIDRequiredError{}).Error()},})return}@@ -235,7 +238,7 @@ func (h *TemplateHandler) UpdateTemplate(c *gin.Context) {if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Invalid request format: " + err.Error()},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -253,10 +256,12 @@ func (h *TemplateHandler) UpdateTemplate(c *gin.Context) {if err := h.templateService.UpdateTemplate(c.Request.Context(), id, updates); err != nil {status := http.StatusInternalServerError- msg := "Failed to update template: " + err.Error()+ var msg stringif err.Error() == "template not found" {status = http.StatusNotFound- msg = "Template not found"+ msg = (&common.TemplateNotFoundError{}).Error()+ } else {+ msg = (&common.TemplateUpdateError{Err: err}).Error()}c.JSON(status, gin.H{"success": false,@@ -294,17 +299,19 @@ func (h *TemplateHandler) DeleteTemplate(c *gin.Context) {if id == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Template ID is required"},+ "data": gin.H{"error": (&common.TemplateIDRequiredError{}).Error()},})return}if err := h.templateService.DeleteTemplate(c.Request.Context(), id); err != nil {status := http.StatusInternalServerError- msg := "Failed to delete template: " + err.Error()+ var msg stringif err.Error() == "template not found" {status = http.StatusNotFound- msg = "Template not found"+ msg = (&common.TemplateNotFoundError{}).Error()+ } else {+ msg = (&common.TemplateDeletionError{Err: err}).Error()}c.JSON(status, gin.H{"success": false,@@ -340,7 +347,7 @@ func (h *TemplateHandler) SaveDefaultTemplates(c *gin.Context) {if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Invalid request format: " + err.Error()},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -348,7 +355,7 @@ func (h *TemplateHandler) SaveDefaultTemplates(c *gin.Context) {if err := h.templateService.SaveComposeTemplate(req.ComposeContent); err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to save compose template: " + err.Error()},+ "data": gin.H{"error": (&common.DefaultTemplateSaveError{Err: err}).Error()},})return}@@ -356,7 +363,7 @@ func (h *TemplateHandler) SaveDefaultTemplates(c *gin.Context) {if err := h.templateService.SaveEnvTemplate(req.EnvContent); err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to save env template: " + err.Error()},+ "data": gin.H{"error": (&common.DefaultTemplateSaveError{Err: err}).Error()},})return}@@ -372,7 +379,7 @@ func (h *TemplateHandler) GetRegistries(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to get registries: " + err.Error()},+ "data": gin.H{"error": (&common.RegistryFetchError{Err: err}).Error()},})return}@@ -381,7 +388,7 @@ func (h *TemplateHandler) GetRegistries(c *gin.Context) {if mapErr != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to map registries: " + mapErr.Error()},+ "data": gin.H{"error": (&common.RegistryFetchError{Err: mapErr}).Error()},})return}@@ -402,7 +409,7 @@ func (h *TemplateHandler) CreateRegistry(c *gin.Context) {if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Invalid request format: " + err.Error()},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -416,7 +423,7 @@ func (h *TemplateHandler) CreateRegistry(c *gin.Context) {if err := h.templateService.CreateRegistry(c.Request.Context(), registry); err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to create registry: " + err.Error()},+ "data": gin.H{"error": (&common.RegistryCreationError{Err: err}).Error()},})return}@@ -441,7 +448,7 @@ func (h *TemplateHandler) UpdateRegistry(c *gin.Context) {if id == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Registry ID is required"},+ "data": gin.H{"error": (&common.RegistryIDRequiredError{}).Error()},})return}@@ -455,7 +462,7 @@ func (h *TemplateHandler) UpdateRegistry(c *gin.Context) {if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Invalid request format: " + err.Error()},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -468,10 +475,12 @@ func (h *TemplateHandler) UpdateRegistry(c *gin.Context) {}if err := h.templateService.UpdateRegistry(c.Request.Context(), id, updates); err != nil {status := http.StatusInternalServerError- msg := "Failed to update registry: " + err.Error()+ var msg stringif err.Error() == "registry not found" {status = http.StatusNotFound- msg = "Registry not found"+ msg = (&common.RegistryNotFoundError{}).Error()+ } else {+ msg = (&common.RegistryUpdateError{Err: err}).Error()}c.JSON(status, gin.H{"success": false,@@ -491,17 +500,19 @@ func (h *TemplateHandler) DeleteRegistry(c *gin.Context) {if id == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Registry ID is required"},+ "data": gin.H{"error": (&common.RegistryIDRequiredError{}).Error()},})return}if err := h.templateService.DeleteRegistry(c.Request.Context(), id); err != nil {status := http.StatusInternalServerError- msg := "Failed to delete registry: " + err.Error()+ var msg stringif err.Error() == "registry not found" {status = http.StatusNotFound- msg = "Registry not found"+ msg = (&common.RegistryNotFoundError{}).Error()+ } else {+ msg = (&common.RegistryDeletionError{Err: err}).Error()}c.JSON(status, gin.H{"success": false,@@ -521,20 +532,20 @@ func (h *TemplateHandler) FetchRegistry(c *gin.Context) {if url == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "URL parameter is required"},+ "data": gin.H{"error": (&common.QueryParameterRequiredError{}).Error()},})return}body, err := h.templateService.FetchRaw(c.Request.Context(), url)if err != nil {- c.JSON(http.StatusBadGateway, gin.H{"success": false, "data": gin.H{"error": "Failed to fetch registry: " + err.Error()}})+ c.JSON(http.StatusBadGateway, gin.H{"success": false, "data": gin.H{"error": (&common.RegistryFetchError{Err: err}).Error()}})return}var registry interface{}if err := json.Unmarshal(body, ®istry); err != nil {- c.JSON(http.StatusBadGateway, gin.H{"success": false, "data": gin.H{"error": "Invalid JSON response: " + err.Error()}})+ c.JSON(http.StatusBadGateway, gin.H{"success": false, "data": gin.H{"error": (&common.InvalidJSONResponseError{Err: err}).Error()}})return}@@ -547,23 +558,23 @@ func (h *TemplateHandler) FetchRegistry(c *gin.Context) {func (h *TemplateHandler) DownloadTemplate(c *gin.Context) {id := c.Param("id")if id == "" {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": "Template ID is required"}})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": (&common.TemplateIDRequiredError{}).Error()}})return}template, err := h.templateService.GetTemplate(c.Request.Context(), id)if err != nil {- c.JSON(http.StatusNotFound, gin.H{"success": false, "data": gin.H{"error": "Template not found"}})+ c.JSON(http.StatusNotFound, gin.H{"success": false, "data": gin.H{"error": (&common.TemplateNotFoundError{}).Error()}})return}if !template.IsRemote {- c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": "Template is already local"}})+ c.JSON(http.StatusBadRequest, gin.H{"success": false, "data": gin.H{"error": (&common.TemplateAlreadyLocalError{}).Error()}})return}localTemplate, err := h.templateService.DownloadTemplate(c.Request.Context(), template)if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": "Failed to download template: " + err.Error()}})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": gin.H{"error": (&common.TemplateDownloadError{Err: err}).Error()}})return}@@ -584,7 +595,7 @@ func (h *TemplateHandler) GetGlobalVariables(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to retrieve global variables: " + err.Error()},+ "data": gin.H{"error": (&common.GlobalVariablesRetrievalError{Err: err}).Error()},})return}@@ -600,7 +611,7 @@ func (h *TemplateHandler) UpdateGlobalVariables(c *gin.Context) {if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Invalid request format: " + err.Error()},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -608,7 +619,7 @@ func (h *TemplateHandler) UpdateGlobalVariables(c *gin.Context) {if err := h.templateService.UpdateGlobalVariables(c.Request.Context(), req.Variables); err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to update global variables: " + err.Error()},+ "data": gin.H{"error": (&common.GlobalVariablesUpdateError{Err: err}).Error()},})return}diff --git a/backend/internal/api/updater_handler.go b/backend/internal/api/updater_handler.goindex 9910ff61d..a52feb67c 100644--- a/backend/internal/api/updater_handler.go+++ b/backend/internal/api/updater_handler.go@@ -5,6 +5,7 @@ import ("strconv""github.com/gin-gonic/gin"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware""github.com/ofkm/arcane-backend/internal/services"@@ -32,7 +33,7 @@ func (h *UpdaterHandler) Run(c *gin.Context) {out, err := h.updaterService.ApplyPending(c.Request.Context(), req.DryRun)if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error()})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": (&common.UpdaterRunError{Err: err}).Error()})return}@@ -54,7 +55,7 @@ func (h *UpdaterHandler) History(c *gin.Context) {history, err := h.updaterService.GetHistory(c.Request.Context(), limit)if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error()})+ c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": (&common.UpdaterHistoryError{Err: err}).Error()})return}c.JSON(http.StatusOK, gin.H{"success": true, "data": history})diff --git a/backend/internal/api/user_handler.go b/backend/internal/api/user_handler.goindex d70819c9a..f15cf098b 100644--- a/backend/internal/api/user_handler.go+++ b/backend/internal/api/user_handler.go@@ -5,6 +5,7 @@ import ("time""github.com/gin-gonic/gin"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware""github.com/ofkm/arcane-backend/internal/models"@@ -38,7 +39,7 @@ func (h *UserHandler) ListUsers(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to list users: " + err.Error()},+ "data": gin.H{"error": (&common.UserListError{Err: err}).Error()},})return}@@ -55,7 +56,7 @@ func (h *UserHandler) CreateUser(c *gin.Context) {if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Invalid request format"},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -64,7 +65,7 @@ func (h *UserHandler) CreateUser(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to hash password"},+ "data": gin.H{"error": (&common.PasswordHashError{Err: err}).Error()},})return}@@ -89,7 +90,7 @@ func (h *UserHandler) CreateUser(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to create user"},+ "data": gin.H{"error": (&common.UserCreationError{Err: err}).Error()},})return}@@ -98,7 +99,7 @@ func (h *UserHandler) CreateUser(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to map user"},+ "data": gin.H{"error": (&common.UserMappingError{Err: err}).Error()},})return}@@ -116,7 +117,7 @@ func (h *UserHandler) GetUser(c *gin.Context) {if err != nil {c.JSON(http.StatusNotFound, gin.H{"success": false,- "data": gin.H{"error": "User not found"},+ "data": gin.H{"error": (&common.UserNotFoundError{}).Error()},})return}@@ -125,7 +126,7 @@ func (h *UserHandler) GetUser(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to map user"},+ "data": gin.H{"error": (&common.UserMappingError{Err: err}).Error()},})return}@@ -143,7 +144,7 @@ func (h *UserHandler) UpdateUser(c *gin.Context) {if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Invalid request format"},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -152,7 +153,7 @@ func (h *UserHandler) UpdateUser(c *gin.Context) {if err != nil {c.JSON(http.StatusNotFound, gin.H{"success": false,- "data": gin.H{"error": "User not found"},+ "data": gin.H{"error": (&common.UserNotFoundError{}).Error()},})return}@@ -175,7 +176,7 @@ func (h *UserHandler) UpdateUser(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to hash password"},+ "data": gin.H{"error": (&common.PasswordHashError{Err: err}).Error()},})return}@@ -189,7 +190,7 @@ func (h *UserHandler) UpdateUser(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to update user"},+ "data": gin.H{"error": (&common.UserUpdateError{Err: err}).Error()},})return}@@ -198,7 +199,7 @@ func (h *UserHandler) UpdateUser(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to map user"},+ "data": gin.H{"error": (&common.UserMappingError{Err: err}).Error()},})return}@@ -216,7 +217,7 @@ func (h *UserHandler) DeleteUser(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to delete user"},+ "data": gin.H{"error": (&common.UserDeletionError{Err: err}).Error()},})return}diff --git a/backend/internal/api/volume_handler.go b/backend/internal/api/volume_handler.goindex 4fe63b861..f2c96b8e3 100644--- a/backend/internal/api/volume_handler.go+++ b/backend/internal/api/volume_handler.go@@ -5,6 +5,7 @@ import ("github.com/docker/docker/api/types/volume""github.com/gin-gonic/gin"+ "github.com/ofkm/arcane-backend/internal/common""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware""github.com/ofkm/arcane-backend/internal/services"@@ -43,7 +44,7 @@ func (h *VolumeHandler) List(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to list volumes: " + err.Error()},+ "data": gin.H{"error": (&common.VolumeListError{Err: err}).Error()},})return}@@ -69,7 +70,7 @@ func (h *VolumeHandler) GetByName(c *gin.Context) {if err != nil {c.JSON(http.StatusNotFound, gin.H{"success": false,- "data": gin.H{"error": err.Error()},+ "data": gin.H{"error": (&common.VolumeNotFoundError{Err: err}).Error()},})return}@@ -85,7 +86,7 @@ func (h *VolumeHandler) Create(c *gin.Context) {if err := c.ShouldBindJSON(&req); err != nil {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "data": gin.H{"error": "Invalid request: " + err.Error()},+ "data": gin.H{"error": (&common.InvalidRequestFormatError{Err: err}).Error()},})return}@@ -106,7 +107,7 @@ func (h *VolumeHandler) Create(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": err.Error()},+ "data": gin.H{"error": (&common.VolumeCreationError{Err: err}).Error()},})return}@@ -129,7 +130,7 @@ func (h *VolumeHandler) Remove(c *gin.Context) {if err := h.volumeService.DeleteVolume(c.Request.Context(), name, force, *currentUser); err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": err.Error()},+ "data": gin.H{"error": (&common.VolumeDeletionError{Err: err}).Error()},})return}@@ -145,7 +146,7 @@ func (h *VolumeHandler) Prune(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": err.Error()},+ "data": gin.H{"error": (&common.VolumePruneError{Err: err}).Error()},})return}@@ -163,7 +164,7 @@ func (h *VolumeHandler) GetUsage(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": err.Error()},+ "data": gin.H{"error": (&common.VolumeUsageError{Err: err}).Error()},})return}@@ -182,7 +183,7 @@ func (h *VolumeHandler) GetVolumeUsageCounts(c *gin.Context) {if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": gin.H{"error": "Failed to get container counts: " + err.Error()},+ "data": gin.H{"error": (&common.VolumeCountsError{Err: err}).Error()},})return}diff --git a/backend/internal/common/errors.go b/backend/internal/common/errors.gonew file mode 100644index 000000000..243eec70d--- /dev/null+++ b/backend/internal/common/errors.go@@ -0,0 +1,1204 @@+package common++import "fmt"++type InvalidRequestFormatError struct {+ Err error+}++func (e *InvalidRequestFormatError) Error() string {+ if e.Err != nil {+ return fmt.Sprintf("Invalid request format: %v", e.Err)+ }+ return "Invalid request format"+}++type AuthSettingsCheckError struct {+ Err error+}++func (e *AuthSettingsCheckError) Error() string {+ return "Failed to check authentication settings"+}++type LocalAuthDisabledError struct{}++func (e *LocalAuthDisabledError) Error() string {+ return "Local authentication is disabled"+}++type InvalidCredentialsError struct{}++func (e *InvalidCredentialsError) Error() string {+ return "Invalid username or password"+}++type AuthFailedError struct {+ Err error+}++func (e *AuthFailedError) Error() string {+ return "Authentication failed"+}++type UserMappingError struct {+ Err error+}++func (e *UserMappingError) Error() string {+ return "Failed to map user"+}++type NotAuthenticatedError struct{}++func (e *NotAuthenticatedError) Error() string {+ return "Not authenticated"+}++type UserRetrievalError struct {+ Err error+}++func (e *UserRetrievalError) Error() string {+ return "Failed to get user information"+}++type InvalidTokenError struct{}++func (e *InvalidTokenError) Error() string {+ return "Invalid or expired refresh token"+}++type TokenRefreshError struct {+ Err error+}++func (e *TokenRefreshError) Error() string {+ return "Failed to refresh token"+}++type PasswordRequiredError struct{}++func (e *PasswordRequiredError) Error() string {+ return "Current password is required"+}++type IncorrectPasswordError struct{}++func (e *IncorrectPasswordError) Error() string {+ return "Current password is incorrect"+}++type PasswordChangeError struct {+ Err error+}++func (e *PasswordChangeError) Error() string {+ return "Failed to change password"+}++type ImageRetrievalError struct {+ Err error+}++func (e *ImageRetrievalError) Error() string {+ return "Failed to retrieve image"+}++type ContainerIDRequiredError struct{}++func (e *ContainerIDRequiredError) Error() string {+ return "Container ID is required"+}++type WebSocketUpgradeError struct {+ Err error+}++func (e *WebSocketUpgradeError) Error() string {+ return fmt.Sprintf("Failed to upgrade connection: %v", e.Err)+}++type ExecCreationError struct {+ Err error+}++func (e *ExecCreationError) Error() string {+ return fmt.Sprintf("Error creating exec: %v", e.Err)+}++type ExecAttachError struct {+ Err error+}++func (e *ExecAttachError) Error() string {+ return fmt.Sprintf("Error attaching to exec: %v", e.Err)+}++type ContainerListError struct {+ Err error+}++func (e *ContainerListError) Error() string {+ return fmt.Sprintf("Failed to list containers: %v", e.Err)+}++type ContainerRetrievalError struct {+ Err error+}++func (e *ContainerRetrievalError) Error() string {+ return fmt.Sprintf("Failed to retrieve container: %v", e.Err)+}++type ContainerStartError struct {+ Err error+}++func (e *ContainerStartError) Error() string {+ return fmt.Sprintf("Failed to start container: %v", e.Err)+}++type ContainerStopError struct {+ Err error+}++func (e *ContainerStopError) Error() string {+ return fmt.Sprintf("Failed to stop container: %v", e.Err)+}++type ContainerRestartError struct {+ Err error+}++func (e *ContainerRestartError) Error() string {+ return fmt.Sprintf("Failed to restart container: %v", e.Err)+}++type ContainerDeleteError struct {+ Err error+}++func (e *ContainerDeleteError) Error() string {+ return fmt.Sprintf("Failed to delete container: %v", e.Err)+}++type ContainerStatusCountsError struct {+ Err error+}++func (e *ContainerStatusCountsError) Error() string {+ return fmt.Sprintf("Failed to get container counts: %v", e.Err)+}++type InvalidPortFormatError struct {+ Err error+}++func (e *InvalidPortFormatError) Error() string {+ return fmt.Sprintf("Invalid port format: %v", e.Err)+}++type ContainerCreationError struct {+ Err error+}++func (e *ContainerCreationError) Error() string {+ return fmt.Sprintf("Failed to create container: %v", e.Err)+}++type RegistryListError struct {+ Err error+}++func (e *RegistryListError) Error() string {+ return fmt.Sprintf("Failed to list registries: %v", e.Err)+}++type RegistryMappingError struct {+ Err error+}++func (e *RegistryMappingError) Error() string {+ return fmt.Sprintf("Failed to map registry: %v", e.Err)+}++type RegistryRetrievalError struct {+ Err error+}++func (e *RegistryRetrievalError) Error() string {+ return fmt.Sprintf("Failed to retrieve registry: %v", e.Err)+}++type RegistryCreationError struct {+ Err error+}++func (e *RegistryCreationError) Error() string {+ return fmt.Sprintf("Failed to create registry: %v", e.Err)+}++type RegistryUpdateError struct {+ Err error+}++func (e *RegistryUpdateError) Error() string {+ return fmt.Sprintf("Failed to update registry: %v", e.Err)+}++type RegistryDeletionError struct {+ Err error+}++func (e *RegistryDeletionError) Error() string {+ return fmt.Sprintf("Failed to delete registry: %v", e.Err)+}++type TokenDecryptionError struct {+ Err error+}++func (e *TokenDecryptionError) Error() string {+ return fmt.Sprintf("Failed to decrypt token: %v", e.Err)+}++type RegistryTestError struct {+ Err error+}++func (e *RegistryTestError) Error() string {+ return fmt.Sprintf("Registry test failed: %v", e.Err)+}++type RegistrySyncError struct {+ Err error+}++func (e *RegistrySyncError) Error() string {+ return fmt.Sprintf("Failed to sync registries: %v", e.Err)+}++type QueryParameterRequiredError struct{}++func (e *QueryParameterRequiredError) Error() string {+ return "Query parameter is required"+}++type EnvironmentNotFoundError struct{}++func (e *EnvironmentNotFoundError) Error() string {+ return "Environment not found"+}++type AgentTokenPersistenceError struct {+ Err error+}++func (e *AgentTokenPersistenceError) Error() string {+ return "Failed to persist agent token"+}++type AgentPairingError struct {+ Err error+}++func (e *AgentPairingError) Error() string {+ return fmt.Sprintf("Agent pairing failed: %v", e.Err)+}++type EnvironmentCreationError struct {+ Err error+}++func (e *EnvironmentCreationError) Error() string {+ return fmt.Sprintf("Failed to create environment: %v", e.Err)+}++type EnvironmentMappingError struct {+ Err error+}++func (e *EnvironmentMappingError) Error() string {+ return "Failed to map environment"+}++type EnvironmentListError struct {+ Err error+}++func (e *EnvironmentListError) Error() string {+ return "Failed to fetch environments"+}++type EnvironmentUpdateError struct {+ Err error+}++func (e *EnvironmentUpdateError) Error() string {+ return "Failed to update environment"+}++type LocalEnvironmentDeletionError struct{}++func (e *LocalEnvironmentDeletionError) Error() string {+ return "Cannot delete local environment"+}++type EnvironmentDeletionError struct {+ Err error+}++func (e *EnvironmentDeletionError) Error() string {+ return fmt.Sprintf("Failed to delete environment: %v", e.Err)+}++type HeartbeatUpdateError struct {+ Err error+}++func (e *HeartbeatUpdateError) Error() string {+ return "Failed to update heartbeat"+}++type EventListError struct {+ Err error+}++func (e *EventListError) Error() string {+ return fmt.Sprintf("Failed to list events: %v", e.Err)+}++type EnvironmentIDRequiredError struct{}++func (e *EnvironmentIDRequiredError) Error() string {+ return "Environment ID is required"+}++type EventCreationError struct {+ Err error+}++func (e *EventCreationError) Error() string {+ return fmt.Sprintf("Failed to create event: %v", e.Err)+}++type EventIDRequiredError struct{}++func (e *EventIDRequiredError) Error() string {+ return "Event ID is required"+}++type EventDeletionError struct {+ Err error+}++func (e *EventDeletionError) Error() string {+ return fmt.Sprintf("Failed to delete event: %v", e.Err)+}++type ImageListError struct {+ Err error+}++func (e *ImageListError) Error() string {+ return fmt.Sprintf("Failed to list images: %v", e.Err)+}++type ImageNotFoundError struct {+ Err error+}++func (e *ImageNotFoundError) Error() string {+ return fmt.Sprintf("Image not found: %v", e.Err)+}++type ImageRemovalError struct {+ Err error+}++func (e *ImageRemovalError) Error() string {+ return fmt.Sprintf("Failed to remove image: %v", e.Err)+}++type ImagePullError struct {+ ImageName string+ Err error+}++func (e *ImagePullError) Error() string {+ return fmt.Sprintf("Failed to pull image '%s': %v", e.ImageName, e.Err)+}++type ImagePruneError struct {+ Err error+}++func (e *ImagePruneError) Error() string {+ return fmt.Sprintf("Failed to prune images: %v", e.Err)+}++type ImageUsageCountsError struct {+ Err error+}++func (e *ImageUsageCountsError) Error() string {+ return fmt.Sprintf("Failed to get image usage counts: %v", e.Err)+}++type InvalidMultipartFormError struct {+ Err error+}++func (e *InvalidMultipartFormError) Error() string {+ return fmt.Sprintf("Invalid multipart form: %v", e.Err)+}++type FileUploadReadError struct {+ Err error+}++func (e *FileUploadReadError) Error() string {+ return fmt.Sprintf("Failed to read upload: %v", e.Err)+}++type NoFileUploadedError struct{}++func (e *NoFileUploadedError) Error() string {+ return "No file uploaded"+}++type InvalidFileFormatError struct{}++func (e *InvalidFileFormatError) Error() string {+ return "Invalid file format. Only Docker image tar archives are allowed (.tar, .tar.gz, .tgz, .tar.xz)"+}++type ImageLoadError struct {+ Err error+}++func (e *ImageLoadError) Error() string {+ return fmt.Sprintf("Failed to load image: %v", e.Err)+}++type ImageRefRequiredError struct{}++func (e *ImageRefRequiredError) Error() string {+ return "imageRef query parameter is required"+}++type ImageUpdateCheckError struct {+ Err error+}++func (e *ImageUpdateCheckError) Error() string {+ return fmt.Sprintf("Failed to check image update: %v", e.Err)+}++type ImageIDRequiredError struct{}++func (e *ImageIDRequiredError) Error() string {+ return "imageId parameter is required"+}++type ImageRefListRequiredError struct{}++func (e *ImageRefListRequiredError) Error() string {+ return "At least one imageRef is required"+}++type BatchImageUpdateCheckError struct {+ Err error+}++func (e *BatchImageUpdateCheckError) Error() string {+ return fmt.Sprintf("Failed to check image updates: %v", e.Err)+}++type AllImageUpdateCheckError struct {+ Err error+}++func (e *AllImageUpdateCheckError) Error() string {+ return fmt.Sprintf("Failed to check all images: %v", e.Err)+}++type UpdateSummaryError struct {+ Err error+}++func (e *UpdateSummaryError) Error() string {+ return fmt.Sprintf("Failed to get update summary: %v", e.Err)+}++type NetworkListError struct {+ Err error+}++func (e *NetworkListError) Error() string {+ return fmt.Sprintf("Failed to list networks: %v", e.Err)+}++type NetworkNotFoundError struct {+ Err error+}++func (e *NetworkNotFoundError) Error() string {+ return fmt.Sprintf("Network not found: %v", e.Err)+}++type NetworkMappingError struct {+ Err error+}++func (e *NetworkMappingError) Error() string {+ return fmt.Sprintf("Failed to map network: %v", e.Err)+}++type NetworkCreationError struct {+ Err error+}++func (e *NetworkCreationError) Error() string {+ return fmt.Sprintf("Failed to create network: %v", e.Err)+}++type NetworkRemovalError struct {+ Err error+}++func (e *NetworkRemovalError) Error() string {+ return fmt.Sprintf("Failed to remove network: %v", e.Err)+}++type NetworkUsageCountsError struct {+ Err error+}++func (e *NetworkUsageCountsError) Error() string {+ return fmt.Sprintf("Failed to get network counts: %v", e.Err)+}++type NetworkPruneError struct {+ Err error+}++func (e *NetworkPruneError) Error() string {+ return fmt.Sprintf("Failed to prune networks: %v", e.Err)+}++type NotificationSettingsListError struct {+ Err error+}++func (e *NotificationSettingsListError) Error() string {+ return fmt.Sprintf("Failed to list notification settings: %v", e.Err)+}++type InvalidNotificationProviderError struct{}++func (e *InvalidNotificationProviderError) Error() string {+ return "invalid provider"+}++type NotificationSettingsNotFoundError struct{}++func (e *NotificationSettingsNotFoundError) Error() string {+ return "Settings not found"+}++type NotificationSettingsUpdateError struct {+ Err error+}++func (e *NotificationSettingsUpdateError) Error() string {+ return fmt.Sprintf("Failed to update notification settings: %v", e.Err)+}++type NotificationSettingsDeletionError struct {+ Err error+}++func (e *NotificationSettingsDeletionError) Error() string {+ return fmt.Sprintf("Failed to delete notification settings: %v", e.Err)+}++type NotificationTestError struct {+ Err error+}++func (e *NotificationTestError) Error() string {+ return fmt.Sprintf("Failed to send test notification: %v", e.Err)+}++type AppriseSettingsNotFoundError struct{}++func (e *AppriseSettingsNotFoundError) Error() string {+ return "Apprise settings not found"+}++type AppriseSettingsUpdateError struct {+ Err error+}++func (e *AppriseSettingsUpdateError) Error() string {+ return fmt.Sprintf("Failed to update Apprise settings: %v", e.Err)+}++type AppriseTestError struct {+ Err error+}++func (e *AppriseTestError) Error() string {+ return fmt.Sprintf("Failed to send Apprise test notification: %v", e.Err)+}++type OidcStatusError struct {+ Err error+}++func (e *OidcStatusError) Error() string {+ return fmt.Sprintf("Failed to retrieve OIDC status: %v", e.Err)+}++type OidcStatusCheckError struct{}++func (e *OidcStatusCheckError) Error() string {+ return "Failed to check OIDC status"+}++type OidcDisabledError struct{}++func (e *OidcDisabledError) Error() string {+ return "OIDC authentication is disabled"+}++type OidcAuthUrlGenerationError struct {+ Err error+}++func (e *OidcAuthUrlGenerationError) Error() string {+ return fmt.Sprintf("Failed to generate OIDC auth URL: %v", e.Err)+}++type OidcStateCookieError struct{}++func (e *OidcStateCookieError) Error() string {+ return "Missing or invalid OIDC state cookie"+}++type OidcCallbackError struct {+ Err error+}++func (e *OidcCallbackError) Error() string {+ return fmt.Sprintf("OIDC callback failed: %v", e.Err)+}++type OidcConfigError struct{}++func (e *OidcConfigError) Error() string {+ return "Failed to get OIDC configuration"+}++type SkipOnboardingError struct {+ Err error+}++func (e *SkipOnboardingError) Error() string {+ return fmt.Sprintf("Failed to skip onboarding: %v", e.Err)+}++type ResetOnboardingError struct {+ Err error+}++func (e *ResetOnboardingError) Error() string {+ return fmt.Sprintf("Failed to reset onboarding: %v", e.Err)+}++type ProjectListError struct {+ Err error+}++func (e *ProjectListError) Error() string {+ return fmt.Sprintf("Failed to list projects: %v", e.Err)+}++type ProjectIDRequiredError struct{}++func (e *ProjectIDRequiredError) Error() string {+ return "Project ID is required"+}++type ProjectDeploymentError struct {+ Err error+}++func (e *ProjectDeploymentError) Error() string {+ return fmt.Sprintf("Failed to deploy project: %v", e.Err)+}++type ProjectDownError struct {+ Err error+}++func (e *ProjectDownError) Error() string {+ return fmt.Sprintf("Failed to bring down project: %v", e.Err)+}++type ProjectCreationError struct {+ Err error+}++func (e *ProjectCreationError) Error() string {+ return fmt.Sprintf("Failed to create project: %v", e.Err)+}++type ProjectDetailsError struct {+ Err error+}++func (e *ProjectDetailsError) Error() string {+ return fmt.Sprintf("Failed to get project details: %v", e.Err)+}++type ProjectRedeploymentError struct {+ Err error+}++func (e *ProjectRedeploymentError) Error() string {+ return fmt.Sprintf("Failed to redeploy project: %v", e.Err)+}++type ProjectDestroyError struct {+ Err error+}++func (e *ProjectDestroyError) Error() string {+ return fmt.Sprintf("Failed to destroy project: %v", e.Err)+}++type ProjectUpdateError struct {+ Err error+}++func (e *ProjectUpdateError) Error() string {+ return fmt.Sprintf("Failed to update project: %v", e.Err)+}++type ProjectRestartError struct {+ Err error+}++func (e *ProjectRestartError) Error() string {+ return fmt.Sprintf("Failed to restart project: %v", e.Err)+}++type ProjectStatusCountsError struct {+ Err error+}++func (e *ProjectStatusCountsError) Error() string {+ return fmt.Sprintf("Failed to get project status counts: %v", e.Err)+}++type SettingsMappingError struct {+ Err error+}++func (e *SettingsMappingError) Error() string {+ return "Failed to map settings"+}++type AuthSettingsUpdateError struct{}++func (e *AuthSettingsUpdateError) Error() string {+ return "Authentication settings can only be updated from the main environment"+}++type SettingsUpdateError struct {+ Err error+}++func (e *SettingsUpdateError) Error() string {+ return "Failed to update settings"+}++type DockerConnectionError struct {+ Err error+}++func (e *DockerConnectionError) Error() string {+ return fmt.Sprintf("Failed to connect to Docker: %v", e.Err)+}++type DockerPingError struct {+ Err error+}++func (e *DockerPingError) Error() string {+ return fmt.Sprintf("Docker is not responsive: %v", e.Err)+}++type DockerVersionError struct {+ Err error+}++func (e *DockerVersionError) Error() string {+ return fmt.Sprintf("Failed to get Docker version: %v", e.Err)+}++type DockerInfoError struct {+ Err error+}++func (e *DockerInfoError) Error() string {+ return fmt.Sprintf("Failed to get Docker info: %v", e.Err)+}++type DockerContainerListError struct {+ Err error+}++func (e *DockerContainerListError) Error() string {+ return fmt.Sprintf("Failed to list containers: %v", e.Err)+}++type DockerImageListError struct {+ Err error+}++func (e *DockerImageListError) Error() string {+ return fmt.Sprintf("Failed to list images: %v", e.Err)+}++type SystemPruneError struct {+ Err error+}++func (e *SystemPruneError) Error() string {+ return fmt.Sprintf("Failed to prune resources: %v", e.Err)+}++type ContainerStartAllError struct {+ Err error+}++func (e *ContainerStartAllError) Error() string {+ return fmt.Sprintf("Failed to start containers: %v", e.Err)+}++type ContainerStartStoppedError struct {+ Err error+}++func (e *ContainerStartStoppedError) Error() string {+ return fmt.Sprintf("Failed to start stopped containers: %v", e.Err)+}++type ContainerStopAllError struct {+ Err error+}++func (e *ContainerStopAllError) Error() string {+ return fmt.Sprintf("Failed to stop containers: %v", e.Err)+}++type DockerRunParseError struct {+ Err error+}++func (e *DockerRunParseError) Error() string {+ return "Failed to parse docker run command. Please check the syntax."+}++type DockerComposeConversionError struct {+ Err error+}++func (e *DockerComposeConversionError) Error() string {+ return "Failed to convert to Docker Compose format."+}++type UpgradeCheckError struct {+ Err error+}++func (e *UpgradeCheckError) Error() string {+ return fmt.Sprintf("Failed to check for updates: %v", e.Err)+}++type UpgradeTriggerError struct {+ Err error+}++func (e *UpgradeTriggerError) Error() string {+ return fmt.Sprintf("Failed to initiate upgrade: %v", e.Err)+}++type TemplateListError struct {+ Err error+}++func (e *TemplateListError) Error() string {+ return fmt.Sprintf("Failed to get templates: %v", e.Err)+}++type TemplateMappingError struct {+ Err error+}++func (e *TemplateMappingError) Error() string {+ return fmt.Sprintf("Failed to map templates: %v", e.Err)+}++type TemplateIDRequiredError struct{}++func (e *TemplateIDRequiredError) Error() string {+ return "Template ID is required"+}++type TemplateNotFoundError struct {+ Err error+}++func (e *TemplateNotFoundError) Error() string {+ if e.Err != nil {+ return fmt.Sprintf("Template not found: %v", e.Err)+ }+ return "Template not found"+}++type TemplateRetrievalError struct {+ Err error+}++func (e *TemplateRetrievalError) Error() string {+ return fmt.Sprintf("Failed to get template: %v", e.Err)+}++type TemplateContentError struct {+ Err error+}++func (e *TemplateContentError) Error() string {+ return fmt.Sprintf("Failed to get template content: %v", e.Err)+}++type TemplateCreationError struct {+ Err error+}++func (e *TemplateCreationError) Error() string {+ return fmt.Sprintf("Failed to create template: %v", e.Err)+}++type TemplateUpdateError struct {+ Err error+}++func (e *TemplateUpdateError) Error() string {+ return fmt.Sprintf("Failed to update template: %v", e.Err)+}++type TemplateDeletionError struct {+ Err error+}++func (e *TemplateDeletionError) Error() string {+ return fmt.Sprintf("Failed to delete template: %v", e.Err)+}++type DefaultTemplateSaveError struct {+ Err error+}++func (e *DefaultTemplateSaveError) Error() string {+ return fmt.Sprintf("Failed to save default template: %v", e.Err)+}++type RegistryIDRequiredError struct{}++func (e *RegistryIDRequiredError) Error() string {+ return "Registry ID is required"+}++type RegistryNotFoundError struct {+ Err error+}++func (e *RegistryNotFoundError) Error() string {+ if e.Err != nil {+ return fmt.Sprintf("Registry not found: %v", e.Err)+ }+ return "Registry not found"+}++type RegistryFetchError struct {+ Err error+}++func (e *RegistryFetchError) Error() string {+ return fmt.Sprintf("Failed to fetch registry: %v", e.Err)+}++type InvalidJSONResponseError struct {+ Err error+}++func (e *InvalidJSONResponseError) Error() string {+ return fmt.Sprintf("Invalid JSON response: %v", e.Err)+}++type TemplateAlreadyLocalError struct{}++func (e *TemplateAlreadyLocalError) Error() string {+ return "Template is already local"+}++type TemplateDownloadError struct {+ Err error+}++func (e *TemplateDownloadError) Error() string {+ return fmt.Sprintf("Failed to download template: %v", e.Err)+}++type GlobalVariablesRetrievalError struct {+ Err error+}++func (e *GlobalVariablesRetrievalError) Error() string {+ return fmt.Sprintf("Failed to retrieve global variables: %v", e.Err)+}++type GlobalVariablesUpdateError struct {+ Err error+}++func (e *GlobalVariablesUpdateError) Error() string {+ return fmt.Sprintf("Failed to update global variables: %v", e.Err)+}++type UpdaterRunError struct {+ Err error+}++func (e *UpdaterRunError) Error() string {+ return fmt.Sprintf("Failed to run updater: %v", e.Err)+}++type UpdaterHistoryError struct {+ Err error+}++func (e *UpdaterHistoryError) Error() string {+ return fmt.Sprintf("Failed to get updater history: %v", e.Err)+}++type UserListError struct {+ Err error+}++func (e *UserListError) Error() string {+ return fmt.Sprintf("Failed to list users: %v", e.Err)+}++type PasswordHashError struct {+ Err error+}++func (e *PasswordHashError) Error() string {+ return "Failed to hash password"+}++type UserCreationError struct {+ Err error+}++func (e *UserCreationError) Error() string {+ return "Failed to create user"+}++type UserNotFoundError struct{}++func (e *UserNotFoundError) Error() string {+ return "User not found"+}++type UserUpdateError struct {+ Err error+}++func (e *UserUpdateError) Error() string {+ return "Failed to update user"+}++type UserDeletionError struct {+ Err error+}++func (e *UserDeletionError) Error() string {+ return "Failed to delete user"+}++type VolumeListError struct {+ Err error+}++func (e *VolumeListError) Error() string {+ return fmt.Sprintf("Failed to list volumes: %v", e.Err)+}++type VolumeNotFoundError struct {+ Err error+}++func (e *VolumeNotFoundError) Error() string {+ if e.Err != nil {+ return fmt.Sprintf("Volume not found: %v", e.Err)+ }+ return "Volume not found"+}++type VolumeCreationError struct {+ Err error+}++func (e *VolumeCreationError) Error() string {+ return fmt.Sprintf("Failed to create volume: %v", e.Err)+}++type VolumeDeletionError struct {+ Err error+}++func (e *VolumeDeletionError) Error() string {+ return fmt.Sprintf("Failed to delete volume: %v", e.Err)+}++type VolumePruneError struct {+ Err error+}++func (e *VolumePruneError) Error() string {+ return fmt.Sprintf("Failed to prune volumes: %v", e.Err)+}++type VolumeUsageError struct {+ Err error+}++func (e *VolumeUsageError) Error() string {+ return fmt.Sprintf("Failed to get volume usage: %v", e.Err)+}++type VolumeCountsError struct {+ Err error+}++func (e *VolumeCountsError) Error() string {+ return fmt.Sprintf("Failed to get volume counts: %v", e.Err)+}