0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-04-05 01:21:17 +02:00
gitea/models/group/errors.go
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 96feb682fe
changes
* move error-related code for groups to its own file

* update group avatar logic

remove unused/duplicate logic

* update `FindGroupsOptions.ToConds()`

allow passing `-1` as the `ParentGroupID`, meaning "find matching groups regardless of the parent group id"

* add `DedupeBy` function to container module

this removes duplicate items from a slice using a custom function

* add `SliceMap` util

works like javascripts's `Array.prototoype.map`, taking in a slice and transforming each element with the provided function

* add group service

functions included so far:
- avatar uploading/deletion
- group deletion
- group creation
- group moving (including moving item inside a group)
- group update
- team management
  - add team
  - remove team
  - update team permissions
  - recalculating team access (in event of group move)
- group searching (only used in frontend/web components for now)
2026-04-02 20:00:45 -04:00

42 lines
827 B
Go

package group
import (
"errors"
"fmt"
"code.gitea.io/gitea/modules/util"
)
type ErrGroupNotExist struct {
ID int64
}
// IsErrGroupNotExist checks if an error is a ErrCommentNotExist.
func IsErrGroupNotExist(err error) bool {
var errGroupNotExist ErrGroupNotExist
ok := errors.As(err, &errGroupNotExist)
return ok
}
func (err ErrGroupNotExist) Error() string {
return fmt.Sprintf("group does not exist [id: %d]", err.ID)
}
func (err ErrGroupNotExist) Unwrap() error {
return util.ErrNotExist
}
type ErrGroupTooDeep struct {
ID int64
}
func IsErrGroupTooDeep(err error) bool {
var errGroupTooDeep ErrGroupTooDeep
ok := errors.As(err, &errGroupTooDeep)
return ok
}
func (err ErrGroupTooDeep) Error() string {
return fmt.Sprintf("group has reached or exceeded the subgroup nesting limit [id: %d]", err.ID)
}