diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2022-12-31 12:49:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-31 12:49:37 +0100 |
commit | 3fef47b41c98392865d13fd21bbcec34236daf4f (patch) | |
tree | 16808c6ea9ffd2cc0438d11831fd3a7503d15056 /models/packages | |
parent | dce8887494268c99ba5da8d5152b5d1cc03cfb83 (diff) | |
download | gitea-3fef47b41c98392865d13fd21bbcec34236daf4f.tar.gz gitea-3fef47b41c98392865d13fd21bbcec34236daf4f.zip |
Use ErrInvalidArgument in packages (#22268)
Related to
https://github.com/go-gitea/gitea/pull/22262#discussion_r1059010774
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'models/packages')
-rw-r--r-- | models/packages/conan/references.go | 6 | ||||
-rw-r--r-- | models/packages/container/search.go | 4 | ||||
-rw-r--r-- | models/packages/package.go | 6 | ||||
-rw-r--r-- | models/packages/package_blob.go | 4 | ||||
-rw-r--r-- | models/packages/package_blob_upload.go | 3 | ||||
-rw-r--r-- | models/packages/package_cleanup_rule.go | 4 | ||||
-rw-r--r-- | models/packages/package_file.go | 6 | ||||
-rw-r--r-- | models/packages/package_version.go | 3 |
8 files changed, 17 insertions, 19 deletions
diff --git a/models/packages/conan/references.go b/models/packages/conan/references.go index 06e828e8fa..0d888a1ec8 100644 --- a/models/packages/conan/references.go +++ b/models/packages/conan/references.go @@ -5,7 +5,6 @@ package conan import ( "context" - "errors" "strconv" "strings" @@ -13,13 +12,14 @@ import ( "code.gitea.io/gitea/models/packages" conan_module "code.gitea.io/gitea/modules/packages/conan" "code.gitea.io/gitea/modules/timeutil" + "code.gitea.io/gitea/modules/util" "xorm.io/builder" ) var ( - ErrRecipeReferenceNotExist = errors.New("Recipe reference does not exist") - ErrPackageReferenceNotExist = errors.New("Package reference does not exist") + ErrRecipeReferenceNotExist = util.NewNotExistErrorf("recipe reference does not exist") + ErrPackageReferenceNotExist = util.NewNotExistErrorf("package reference does not exist") ) // RecipeExists checks if a recipe exists diff --git a/models/packages/container/search.go b/models/packages/container/search.go index dfd5e244ba..2e35c44766 100644 --- a/models/packages/container/search.go +++ b/models/packages/container/search.go @@ -5,7 +5,6 @@ package container import ( "context" - "errors" "strings" "time" @@ -13,11 +12,12 @@ import ( "code.gitea.io/gitea/models/packages" user_model "code.gitea.io/gitea/models/user" container_module "code.gitea.io/gitea/modules/packages/container" + "code.gitea.io/gitea/modules/util" "xorm.io/builder" ) -var ErrContainerBlobNotExist = errors.New("Container blob does not exist") +var ErrContainerBlobNotExist = util.NewNotExistErrorf("container blob does not exist") type BlobSearchOptions struct { OwnerID int64 diff --git a/models/packages/package.go b/models/packages/package.go index 5c4837d98b..a804f35de3 100644 --- a/models/packages/package.go +++ b/models/packages/package.go @@ -5,11 +5,11 @@ package packages import ( "context" - "errors" "fmt" "strings" "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/modules/util" "xorm.io/builder" ) @@ -20,9 +20,9 @@ func init() { var ( // ErrDuplicatePackage indicates a duplicated package error - ErrDuplicatePackage = errors.New("Package does exist already") + ErrDuplicatePackage = util.NewAlreadyExistErrorf("package already exists") // ErrPackageNotExist indicates a package not exist error - ErrPackageNotExist = errors.New("Package does not exist") + ErrPackageNotExist = util.NewNotExistErrorf("package does not exist") ) // Type of a package diff --git a/models/packages/package_blob.go b/models/packages/package_blob.go index 36ad745312..3b4a1ecf18 100644 --- a/models/packages/package_blob.go +++ b/models/packages/package_blob.go @@ -5,15 +5,15 @@ package packages import ( "context" - "errors" "time" "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" + "code.gitea.io/gitea/modules/util" ) // ErrPackageBlobNotExist indicates a package blob not exist error -var ErrPackageBlobNotExist = errors.New("Package blob does not exist") +var ErrPackageBlobNotExist = util.NewNotExistErrorf("package blob does not exist") func init() { db.RegisterModel(new(PackageBlob)) diff --git a/models/packages/package_blob_upload.go b/models/packages/package_blob_upload.go index 64d1f9d473..4b0e789221 100644 --- a/models/packages/package_blob_upload.go +++ b/models/packages/package_blob_upload.go @@ -5,7 +5,6 @@ package packages import ( "context" - "errors" "strings" "time" @@ -15,7 +14,7 @@ import ( ) // ErrPackageBlobUploadNotExist indicates a package blob upload not exist error -var ErrPackageBlobUploadNotExist = errors.New("Package blob upload does not exist") +var ErrPackageBlobUploadNotExist = util.NewNotExistErrorf("package blob upload does not exist") func init() { db.RegisterModel(new(PackageBlobUpload)) diff --git a/models/packages/package_cleanup_rule.go b/models/packages/package_cleanup_rule.go index 9bd512755d..fa12dec406 100644 --- a/models/packages/package_cleanup_rule.go +++ b/models/packages/package_cleanup_rule.go @@ -5,17 +5,17 @@ package packages import ( "context" - "errors" "fmt" "regexp" "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" + "code.gitea.io/gitea/modules/util" "xorm.io/builder" ) -var ErrPackageCleanupRuleNotExist = errors.New("Package blob does not exist") +var ErrPackageCleanupRuleNotExist = util.NewNotExistErrorf("package blob does not exist") func init() { db.RegisterModel(new(PackageCleanupRule)) diff --git a/models/packages/package_file.go b/models/packages/package_file.go index 6d0fd185a0..7f794836dc 100644 --- a/models/packages/package_file.go +++ b/models/packages/package_file.go @@ -5,13 +5,13 @@ package packages import ( "context" - "errors" "strconv" "strings" "time" "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" + "code.gitea.io/gitea/modules/util" "xorm.io/builder" ) @@ -22,9 +22,9 @@ func init() { var ( // ErrDuplicatePackageFile indicates a duplicated package file error - ErrDuplicatePackageFile = errors.New("Package file does exist already") + ErrDuplicatePackageFile = util.NewAlreadyExistErrorf("package file already exists") // ErrPackageFileNotExist indicates a package file not exist error - ErrPackageFileNotExist = errors.New("Package file does not exist") + ErrPackageFileNotExist = util.NewNotExistErrorf("package file does not exist") ) // EmptyFileKey is a named constant for an empty file key diff --git a/models/packages/package_version.go b/models/packages/package_version.go index 928f9d47d6..759c20abed 100644 --- a/models/packages/package_version.go +++ b/models/packages/package_version.go @@ -5,7 +5,6 @@ package packages import ( "context" - "errors" "strconv" "strings" @@ -17,7 +16,7 @@ import ( ) // ErrDuplicatePackageVersion indicates a duplicated package version error -var ErrDuplicatePackageVersion = errors.New("Package version already exists") +var ErrDuplicatePackageVersion = util.NewAlreadyExistErrorf("package version already exists") func init() { db.RegisterModel(new(PackageVersion)) |