mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-23 11:54:38 +00:00
refactor: clean up error system (#40328)
1. `ctx.ServerError("LogMessage", err)` is very messy and useless. When
the log is printed, it already contains the caller's file and line
number
2. `ctx.NotFound(nil)` and `ctx.NotFound(err)` were abused a lot, now
only `ctx.NotFound()`
---------
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
1 parent
a61ef7aa14
commit
b3422c0920
167 files changed
+1530
-1773
No files matched your search
+1
-4
@@ -22,9 +22,6 @@ var hookNames = []string{
|
||||
"post-receive",
|
||||
}
|
||||
|
||||
// ErrNotValidHook error when a git hook is not valid
|
||||
var ErrNotValidHook = errors.New("not a valid Git hook")
|
||||
|
||||
// IsValidHookName returns true if given name is a valid Git hook.
|
||||
func IsValidHookName(name string) bool {
|
||||
return slices.Contains(hookNames, name)
|
||||
@@ -43,7 +40,7 @@ type Hook struct {
|
||||
func GetHook(repo RepositoryFacade, name string) (*Hook, error) {
|
||||
repoPath := gitrepo.RepoLocalPath(repo)
|
||||
if !IsValidHookName(name) {
|
||||
return nil, ErrNotValidHook
|
||||
return nil, util.NewNotExistErrorf("invalid hook name: %s", name)
|
||||
}
|
||||
h := &Hook{
|
||||
name: name,
|
||||
|
||||
Reference in new issue
Block a user