diff --git a/api/http/handler/auth/authenticate.go b/api/http/handler/auth/authenticate.go index 87d075d49..90521afa4 100644 --- a/api/http/handler/auth/authenticate.go +++ b/api/http/handler/auth/authenticate.go @@ -74,7 +74,7 @@ func (handler *Handler) authenticate(rw http.ResponseWriter, r *http.Request) *h if settings.AuthenticationMethod == portainer.AuthenticationInternal || settings.AuthenticationMethod == portainer.AuthenticationOAuth || (settings.AuthenticationMethod == portainer.AuthenticationLDAP && !settings.LDAPSettings.AutoCreateUsers) { - return &httperror.HandlerError{StatusCode: http.StatusUnprocessableEntity, Message: "Invalid credentials", Err: httperrors.ErrUnauthorized} + return httperror.NewError(http.StatusUnprocessableEntity, "Invalid credentials", httperrors.ErrUnauthorized) } } @@ -83,14 +83,14 @@ func (handler *Handler) authenticate(rw http.ResponseWriter, r *http.Request) *h } if settings.AuthenticationMethod == portainer.AuthenticationOAuth { - return &httperror.HandlerError{StatusCode: http.StatusUnprocessableEntity, Message: "Only initial admin is allowed to login without oauth", Err: httperrors.ErrUnauthorized} + return httperror.NewError(http.StatusUnprocessableEntity, "Only initial admin is allowed to login without oauth", httperrors.ErrUnauthorized) } if settings.AuthenticationMethod == portainer.AuthenticationLDAP { return handler.authenticateLDAP(rw, user, payload.Username, payload.Password, &settings.LDAPSettings) } - return &httperror.HandlerError{StatusCode: http.StatusUnprocessableEntity, Message: "Login method is not supported", Err: httperrors.ErrUnauthorized} + return httperror.NewError(http.StatusUnprocessableEntity, "Login method is not supported", httperrors.ErrUnauthorized) } func isUserInitialAdmin(user *portainer.User) bool { @@ -100,7 +100,7 @@ func isUserInitialAdmin(user *portainer.User) bool { func (handler *Handler) authenticateInternal(w http.ResponseWriter, user *portainer.User, password string) *httperror.HandlerError { err := handler.CryptoService.CompareHashAndData(user.Password, password) if err != nil { - return &httperror.HandlerError{StatusCode: http.StatusUnprocessableEntity, Message: "Invalid credentials", Err: httperrors.ErrUnauthorized} + return httperror.NewError(http.StatusUnprocessableEntity, "Invalid credentials", httperrors.ErrUnauthorized) } forceChangePassword := !handler.passwordStrengthChecker.Check(password) diff --git a/api/http/handler/edgegroups/edgegroup_delete.go b/api/http/handler/edgegroups/edgegroup_delete.go index beb82c167..f6ad932d3 100644 --- a/api/http/handler/edgegroups/edgegroup_delete.go +++ b/api/http/handler/edgegroups/edgegroup_delete.go @@ -59,7 +59,7 @@ func deleteEdgeGroup(tx dataservices.DataStoreTx, ID portainer.EdgeGroupID) erro for _, edgeStack := range edgeStacks { for _, groupID := range edgeStack.EdgeGroups { if groupID == ID { - return httperror.NewError(http.StatusConflict, "Edge group is used by an Edge stack", errors.New("edge group is used by an Edge stack")) + return httperror.Conflict("Edge group is used by an Edge stack", errors.New("edge group is used by an Edge stack")) } } } @@ -72,7 +72,7 @@ func deleteEdgeGroup(tx dataservices.DataStoreTx, ID portainer.EdgeGroupID) erro for _, edgeJob := range edgeJobs { for _, groupID := range edgeJob.EdgeGroups { if groupID == ID { - return httperror.NewError(http.StatusConflict, "Edge group is used by an Edge job", errors.New("edge group is used by an Edge job")) + return httperror.Conflict("Edge group is used by an Edge job", errors.New("edge group is used by an Edge job")) } } } diff --git a/api/http/handler/edgestacks/edgestack_create.go b/api/http/handler/edgestacks/edgestack_create.go index 78345bebd..5fdc43590 100644 --- a/api/http/handler/edgestacks/edgestack_create.go +++ b/api/http/handler/edgestacks/edgestack_create.go @@ -36,7 +36,7 @@ func (handler *Handler) edgeStackCreate(w http.ResponseWriter, r *http.Request) case httperrors.IsInvalidPayloadError(err): return httperror.BadRequest("Invalid payload", err) case httperrors.IsConflictError(err): - return httperror.NewError(http.StatusConflict, err.Error(), err) + return httperror.Conflict(err.Error(), err) default: return httperror.InternalServerError("Unable to create Edge stack", err) } diff --git a/api/http/handler/endpoints/endpoint_create.go b/api/http/handler/endpoints/endpoint_create.go index b2acded9a..12449ab35 100644 --- a/api/http/handler/endpoints/endpoint_create.go +++ b/api/http/handler/endpoints/endpoint_create.go @@ -216,7 +216,7 @@ func (handler *Handler) endpointCreate(w http.ResponseWriter, r *http.Request) * } if !isUnique { - return httperror.NewError(http.StatusConflict, "Name is not unique", nil) + return httperror.Conflict("Name is not unique", nil) } endpoint, endpointCreationError := handler.createEndpoint(handler.DataStore, payload) diff --git a/api/http/handler/endpoints/endpoint_update.go b/api/http/handler/endpoints/endpoint_update.go index 6c2264338..8a1d1a1a5 100644 --- a/api/http/handler/endpoints/endpoint_update.go +++ b/api/http/handler/endpoints/endpoint_update.go @@ -100,7 +100,7 @@ func (handler *Handler) endpointUpdate(w http.ResponseWriter, r *http.Request) * } if !isUnique { - return httperror.NewError(http.StatusConflict, "Name is not unique", nil) + return httperror.Conflict("Name is not unique", nil) } endpoint.Name = name diff --git a/api/http/handler/hostmanagement/fdo/profile_create.go b/api/http/handler/hostmanagement/fdo/profile_create.go index afe80a80d..0fbabeda2 100644 --- a/api/http/handler/hostmanagement/fdo/profile_create.go +++ b/api/http/handler/hostmanagement/fdo/profile_create.go @@ -69,7 +69,7 @@ func (handler *Handler) createFDOProfileFromFileContent(w http.ResponseWriter, r } if !isUnique { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: fmt.Sprintf("A profile with the name '%s' already exists", payload.Name), Err: errors.New("a profile already exists with this name")} + return httperror.Conflict(fmt.Sprintf("A profile with the name '%s' already exists", payload.Name), errors.New("a profile already exists with this name")) } profileID := handler.DataStore.FDOProfile().GetNextIdentifier() diff --git a/api/http/handler/hostmanagement/fdo/profile_update.go b/api/http/handler/hostmanagement/fdo/profile_update.go index 5820d5b5c..6af0bb007 100644 --- a/api/http/handler/hostmanagement/fdo/profile_update.go +++ b/api/http/handler/hostmanagement/fdo/profile_update.go @@ -49,7 +49,7 @@ func (handler *Handler) updateProfile(w http.ResponseWriter, r *http.Request) *h return httperror.InternalServerError(err.Error(), err) } if !isUnique { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: fmt.Sprintf("A profile with the name '%s' already exists", payload.Name), Err: errors.New("a profile already exists with this name")} + return httperror.Conflict(fmt.Sprintf("A profile with the name '%s' already exists", payload.Name), errors.New("a profile already exists with this name")) } filePath, err := handler.FileService.StoreFDOProfileFileFromBytes(strconv.Itoa(int(profile.ID)), []byte(payload.ProfileFileContent)) diff --git a/api/http/handler/registries/registry_create.go b/api/http/handler/registries/registry_create.go index 9a3e92c8e..2ddf86b56 100644 --- a/api/http/handler/registries/registry_create.go +++ b/api/http/handler/registries/registry_create.go @@ -128,10 +128,10 @@ func (handler *Handler) registryCreate(w http.ResponseWriter, r *http.Request) * } for _, r := range registries { if r.Name == registry.Name { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: "Another registry with the same name already exists", Err: errors.New("A registry is already defined with this name")} + return httperror.Conflict("Another registry with the same name already exists", errors.New("A registry is already defined with this name")) } if handler.registriesHaveSameURLAndCredentials(&r, registry) { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: "Another registry with the same URL and credentials already exists", Err: errors.New("A registry is already defined for this URL and credentials")} + return httperror.Conflict("Another registry with the same URL and credentials already exists", errors.New("A registry is already defined for this URL and credentials")) } } diff --git a/api/http/handler/registries/registry_update.go b/api/http/handler/registries/registry_update.go index 120747fb3..c98b52dae 100644 --- a/api/http/handler/registries/registry_update.go +++ b/api/http/handler/registries/registry_update.go @@ -97,7 +97,7 @@ func (handler *Handler) registryUpdate(w http.ResponseWriter, r *http.Request) * // see https://portainer.atlassian.net/browse/EE-2706 for more details for _, r := range registries { if r.ID != registry.ID && r.Name == registry.Name { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: "Another registry with the same name already exists", Err: errors.New("A registry is already defined with this name")} + return httperror.Conflict("Another registry with the same name already exists", errors.New("A registry is already defined with this name")) } } @@ -148,7 +148,7 @@ func (handler *Handler) registryUpdate(w http.ResponseWriter, r *http.Request) * for _, r := range registries { if r.ID != registry.ID && handler.registriesHaveSameURLAndCredentials(&r, registry) { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: "Another registry with the same URL and credentials already exists", Err: errors.New("A registry is already defined for this URL and credentials")} + return httperror.Conflict("Another registry with the same URL and credentials already exists", errors.New("A registry is already defined for this URL and credentials")) } } } diff --git a/api/http/handler/resourcecontrols/resourcecontrol_create.go b/api/http/handler/resourcecontrols/resourcecontrol_create.go index 1a8982a79..38eeed085 100644 --- a/api/http/handler/resourcecontrols/resourcecontrol_create.go +++ b/api/http/handler/resourcecontrols/resourcecontrol_create.go @@ -78,7 +78,7 @@ func (handler *Handler) resourceControlCreate(w http.ResponseWriter, r *http.Req return httperror.InternalServerError("Unable to retrieve resource controls from the database", err) } if rc != nil { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: "A resource control is already associated to this resource", Err: errResourceControlAlreadyExists} + return httperror.Conflict("A resource control is already associated to this resource", errResourceControlAlreadyExists) } var userAccesses = make([]portainer.UserResourceAccess, 0) diff --git a/api/http/handler/stacks/create_compose_stack.go b/api/http/handler/stacks/create_compose_stack.go index 5e0bf3982..d3c99f79a 100644 --- a/api/http/handler/stacks/create_compose_stack.go +++ b/api/http/handler/stacks/create_compose_stack.go @@ -272,7 +272,7 @@ func (handler *Handler) createComposeStackFromGitRepository(w http.ResponseWrite return httperror.InternalServerError("Unable to check for webhook ID collision", err) } if !isUnique { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: fmt.Sprintf("Webhook ID: %s already exists", payload.AutoUpdate.Webhook), Err: stackutils.ErrWebhookIDAlreadyExists} + return httperror.Conflict(fmt.Sprintf("Webhook ID: %s already exists", payload.AutoUpdate.Webhook), stackutils.ErrWebhookIDAlreadyExists) } } diff --git a/api/http/handler/stacks/create_kubernetes_stack.go b/api/http/handler/stacks/create_kubernetes_stack.go index 2d66df1c8..979bff0ce 100644 --- a/api/http/handler/stacks/create_kubernetes_stack.go +++ b/api/http/handler/stacks/create_kubernetes_stack.go @@ -166,7 +166,7 @@ func (handler *Handler) createKubernetesStackFromFileContent(w http.ResponseWrit return httperror.InternalServerError("Unable to check for name collision", err) } if !isUnique { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: fmt.Sprintf("A stack with the name '%s' already exists", payload.StackName), Err: stackutils.ErrStackAlreadyExists} + return httperror.Conflict(fmt.Sprintf("A stack with the name '%s' already exists", payload.StackName), stackutils.ErrStackAlreadyExists) } stackPayload := createStackPayloadFromK8sFileContentPayload(payload.StackName, payload.Namespace, payload.StackFileContent, payload.ComposeFormat, payload.FromAppTemplate) @@ -231,7 +231,7 @@ func (handler *Handler) createKubernetesStackFromGitRepository(w http.ResponseWr return httperror.InternalServerError("Unable to check for name collision", err) } if !isUnique { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: fmt.Sprintf("A stack with the name '%s' already exists", payload.StackName), Err: stackutils.ErrStackAlreadyExists} + return httperror.Conflict(fmt.Sprintf("A stack with the name '%s' already exists", payload.StackName), stackutils.ErrStackAlreadyExists) } //make sure the webhook ID is unique @@ -241,7 +241,7 @@ func (handler *Handler) createKubernetesStackFromGitRepository(w http.ResponseWr return httperror.InternalServerError("Unable to check for webhook ID collision", err) } if !isUnique { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: fmt.Sprintf("Webhook ID: %s already exists", payload.AutoUpdate.Webhook), Err: stackutils.ErrWebhookIDAlreadyExists} + return httperror.Conflict(fmt.Sprintf("Webhook ID: %s already exists", payload.AutoUpdate.Webhook), stackutils.ErrWebhookIDAlreadyExists) } } @@ -309,7 +309,7 @@ func (handler *Handler) createKubernetesStackFromManifestURL(w http.ResponseWrit return httperror.InternalServerError("Unable to check for name collision", err) } if !isUnique { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: fmt.Sprintf("A stack with the name '%s' already exists", payload.StackName), Err: stackutils.ErrStackAlreadyExists} + return httperror.Conflict(fmt.Sprintf("A stack with the name '%s' already exists", payload.StackName), stackutils.ErrStackAlreadyExists) } stackPayload := createStackPayloadFromK8sUrlPayload(payload.StackName, diff --git a/api/http/handler/stacks/create_swarm_stack.go b/api/http/handler/stacks/create_swarm_stack.go index 192ebdb1b..de9ae7939 100644 --- a/api/http/handler/stacks/create_swarm_stack.go +++ b/api/http/handler/stacks/create_swarm_stack.go @@ -214,7 +214,7 @@ func (handler *Handler) createSwarmStackFromGitRepository(w http.ResponseWriter, return httperror.InternalServerError("Unable to check for webhook ID collision", err) } if !isUnique { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: fmt.Sprintf("Webhook ID: %s already exists", payload.AutoUpdate.Webhook), Err: stackutils.ErrWebhookIDAlreadyExists} + return httperror.Conflict(fmt.Sprintf("Webhook ID: %s already exists", payload.AutoUpdate.Webhook), stackutils.ErrWebhookIDAlreadyExists) } } diff --git a/api/http/handler/stacks/handler.go b/api/http/handler/stacks/handler.go index 7615738db..ef47fb039 100644 --- a/api/http/handler/stacks/handler.go +++ b/api/http/handler/stacks/handler.go @@ -46,7 +46,7 @@ type Handler struct { func stackExistsError(name string) *httperror.HandlerError { msg := fmt.Sprintf("A stack with the normalized name '%s' already exists", name) err := errors.New(msg) - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: msg, Err: err} + return httperror.Conflict(msg, err) } // NewHandler creates a handler to manage stack operations. diff --git a/api/http/handler/stacks/stack_delete.go b/api/http/handler/stacks/stack_delete.go index 0d8bb2fab..6148da14f 100644 --- a/api/http/handler/stacks/stack_delete.go +++ b/api/http/handler/stacks/stack_delete.go @@ -151,7 +151,7 @@ func (handler *Handler) deleteExternalStack(r *http.Request, w http.ResponseWrit } if !securityContext.IsAdmin { - return &httperror.HandlerError{StatusCode: http.StatusUnauthorized, Message: "Permission denied to delete the stack", Err: httperrors.ErrUnauthorized} + return httperror.Unauthorized("Permission denied to delete the stack", httperrors.ErrUnauthorized) } stack, err := handler.DataStore.Stack().StackByName(stackName) diff --git a/api/http/handler/stacks/stack_migrate.go b/api/http/handler/stacks/stack_migrate.go index 61d60e149..69969478f 100644 --- a/api/http/handler/stacks/stack_migrate.go +++ b/api/http/handler/stacks/stack_migrate.go @@ -145,7 +145,7 @@ func (handler *Handler) stackMigrate(w http.ResponseWriter, r *http.Request) *ht if !isUnique { errorMessage := fmt.Sprintf("A stack with the name '%s' is already running on endpoint '%s'", stack.Name, targetEndpoint.Name) - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: errorMessage, Err: errors.New(errorMessage)} + return httperror.Conflict(errorMessage, errors.New(errorMessage)) } migrationError := handler.migrateStack(r, stack, targetEndpoint) diff --git a/api/http/handler/stacks/stack_start.go b/api/http/handler/stacks/stack_start.go index 868006499..36812bd04 100644 --- a/api/http/handler/stacks/stack_start.go +++ b/api/http/handler/stacks/stack_start.go @@ -85,7 +85,7 @@ func (handler *Handler) stackStart(w http.ResponseWriter, r *http.Request) *http } if !isUnique { errorMessage := fmt.Sprintf("A stack with the name '%s' is already running", stack.Name) - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: errorMessage, Err: errors.New(errorMessage)} + return httperror.Conflict(errorMessage, errors.New(errorMessage)) } resourceControl, err := handler.DataStore.ResourceControl().ResourceControlByResourceIDAndType(stackutils.ResourceControlID(stack.EndpointID, stack.Name), portainer.StackResourceControl) diff --git a/api/http/handler/stacks/webhook_invoke.go b/api/http/handler/stacks/webhook_invoke.go index d32fd67bf..47762f958 100644 --- a/api/http/handler/stacks/webhook_invoke.go +++ b/api/http/handler/stacks/webhook_invoke.go @@ -35,13 +35,13 @@ func (handler *Handler) webhookInvoke(w http.ResponseWriter, r *http.Request) *h statusCode = http.StatusNotFound } - return &httperror.HandlerError{StatusCode: statusCode, Message: "Unable to find the stack by webhook ID", Err: err} + return httperror.NewError(statusCode, "Unable to find the stack by webhook ID", err) } if err = deployments.RedeployWhenChanged(stack.ID, handler.StackDeployer, handler.DataStore, handler.GitService); err != nil { var StackAuthorMissingErr *deployments.StackAuthorMissingErr if errors.As(err, &StackAuthorMissingErr) { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: "Autoupdate for the stack isn't available", Err: err} + return httperror.Conflict("Autoupdate for the stack isn't available", err) } return httperror.InternalServerError("Failed to update the stack", err) diff --git a/api/http/handler/tags/tag_create.go b/api/http/handler/tags/tag_create.go index 1bb4212f3..55e5f55fd 100644 --- a/api/http/handler/tags/tag_create.go +++ b/api/http/handler/tags/tag_create.go @@ -62,7 +62,7 @@ func createTag(tx dataservices.DataStoreTx, payload tagCreatePayload) (*portaine for _, tag := range tags { if tag.Name == payload.Name { - return nil, &httperror.HandlerError{StatusCode: http.StatusConflict, Message: "This name is already associated to a tag", Err: errors.New("a tag already exists with this name")} + return nil, httperror.Conflict("This name is already associated to a tag", errors.New("a tag already exists with this name")) } } diff --git a/api/http/handler/teammemberships/teammembership_create.go b/api/http/handler/teammemberships/teammembership_create.go index 16899e6fd..9be4566f8 100644 --- a/api/http/handler/teammemberships/teammembership_create.go +++ b/api/http/handler/teammemberships/teammembership_create.go @@ -75,7 +75,7 @@ func (handler *Handler) teamMembershipCreate(w http.ResponseWriter, r *http.Requ if len(memberships) > 0 { for _, membership := range memberships { if membership.UserID == portainer.UserID(payload.UserID) && membership.TeamID == portainer.TeamID(payload.TeamID) { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: "Team membership already registered", Err: errors.New("Team membership already exists for this user and team")} + return httperror.Conflict("Team membership already registered", errors.New("Team membership already exists for this user and team")) } } } diff --git a/api/http/handler/teams/team_create.go b/api/http/handler/teams/team_create.go index f4fc76702..d2325a8f1 100644 --- a/api/http/handler/teams/team_create.go +++ b/api/http/handler/teams/team_create.go @@ -53,7 +53,7 @@ func (handler *Handler) teamCreate(w http.ResponseWriter, r *http.Request) *http return httperror.InternalServerError("Unable to retrieve teams from the database", err) } if team != nil { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: "A team with the same name already exists", Err: errors.New("Team already exists")} + return httperror.Conflict("A team with the same name already exists", errors.New("Team already exists")) } team = &portainer.Team{ diff --git a/api/http/handler/users/admin_init.go b/api/http/handler/users/admin_init.go index 1eb0f5734..753ec97a6 100644 --- a/api/http/handler/users/admin_init.go +++ b/api/http/handler/users/admin_init.go @@ -55,7 +55,7 @@ func (handler *Handler) adminInit(w http.ResponseWriter, r *http.Request) *httpe } if len(users) != 0 { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: "Unable to create administrator user", Err: errAdminAlreadyInitialized} + return httperror.Conflict("Unable to create administrator user", errAdminAlreadyInitialized) } if !handler.passwordStrengthChecker.Check(payload.Password) { diff --git a/api/http/handler/users/user_create.go b/api/http/handler/users/user_create.go index 8ba4e16fa..d932b8c43 100644 --- a/api/http/handler/users/user_create.go +++ b/api/http/handler/users/user_create.go @@ -59,7 +59,7 @@ func (handler *Handler) userCreate(w http.ResponseWriter, r *http.Request) *http return httperror.InternalServerError("Unable to retrieve users from the database", err) } if user != nil { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: "Another user with the same username already exists", Err: errUserAlreadyExists} + return httperror.Conflict("Another user with the same username already exists", errUserAlreadyExists) } user = &portainer.User{ diff --git a/api/http/handler/users/user_update.go b/api/http/handler/users/user_update.go index 06e121bd7..7f10194e0 100644 --- a/api/http/handler/users/user_update.go +++ b/api/http/handler/users/user_update.go @@ -107,7 +107,7 @@ func (handler *Handler) userUpdate(w http.ResponseWriter, r *http.Request) *http return httperror.InternalServerError("Unable to retrieve users from the database", err) } if sameNameUser != nil && sameNameUser.ID != portainer.UserID(userID) { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: "Another user with the same username already exists", Err: errUserAlreadyExists} + return httperror.Conflict("Another user with the same username already exists", errUserAlreadyExists) } user.Username = payload.Username diff --git a/api/http/handler/webhooks/webhook_create.go b/api/http/handler/webhooks/webhook_create.go index 1f840e7b1..6e2a6b348 100644 --- a/api/http/handler/webhooks/webhook_create.go +++ b/api/http/handler/webhooks/webhook_create.go @@ -61,7 +61,7 @@ func (handler *Handler) webhookCreate(w http.ResponseWriter, r *http.Request) *h return httperror.InternalServerError("An error occurred retrieving webhooks from the database", err) } if webhook != nil { - return &httperror.HandlerError{StatusCode: http.StatusConflict, Message: "A webhook for this resource already exists", Err: errors.New("A webhook for this resource already exists")} + return httperror.Conflict("A webhook for this resource already exists", errors.New("A webhook for this resource already exists")) } endpointID := payload.EndpointID diff --git a/pkg/libhttp/error/status.go b/pkg/libhttp/error/status.go index f9f3342f6..4853e1024 100644 --- a/pkg/libhttp/error/status.go +++ b/pkg/libhttp/error/status.go @@ -40,3 +40,7 @@ func Unauthorized(message string, err error) *HandlerError { func Forbidden(message string, err error) *HandlerError { return NewError(http.StatusForbidden, message, err) } + +func Conflict(message string, err error) *HandlerError { + return NewError(http.StatusConflict, message, err) +}