aboutsummaryrefslogtreecommitdiffstats
path: root/models/error.go
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2017-10-15 22:59:24 +0300
committerGitHub <noreply@github.com>2017-10-15 22:59:24 +0300
commitf3833b7ce4dc78095194808c6e07d8ae133e7ab5 (patch)
treecdcb53731d4523f068a6e532bf5da9e2759f8cb2 /models/error.go
parentc25303b11c323045718a5af373c11f5807f77fb7 (diff)
downloadgitea-f3833b7ce4dc78095194808c6e07d8ae133e7ab5.tar.gz
gitea-f3833b7ce4dc78095194808c6e07d8ae133e7ab5.zip
Create new branch from branch selection dropdown (#2130)
* Create new branch from branch selection dropdown and rewrite it to VueJS * Make updateLocalCopyToCommit as not exported * Move branch name validation to model * Fix possible race condition
Diffstat (limited to 'models/error.go')
-rw-r--r--models/error.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/models/error.go b/models/error.go
index 37505e8aa5..aa9db7abef 100644
--- a/models/error.go
+++ b/models/error.go
@@ -649,6 +649,51 @@ func (err ErrBranchNotExist) Error() string {
return fmt.Sprintf("branch does not exist [name: %s]", err.Name)
}
+// ErrBranchAlreadyExists represents an error that branch with such name already exists
+type ErrBranchAlreadyExists struct {
+ BranchName string
+}
+
+// IsErrBranchAlreadyExists checks if an error is an ErrBranchAlreadyExists.
+func IsErrBranchAlreadyExists(err error) bool {
+ _, ok := err.(ErrBranchAlreadyExists)
+ return ok
+}
+
+func (err ErrBranchAlreadyExists) Error() string {
+ return fmt.Sprintf("branch already exists [name: %s]", err.BranchName)
+}
+
+// ErrBranchNameConflict represents an error that branch name conflicts with other branch
+type ErrBranchNameConflict struct {
+ BranchName string
+}
+
+// IsErrBranchNameConflict checks if an error is an ErrBranchNameConflict.
+func IsErrBranchNameConflict(err error) bool {
+ _, ok := err.(ErrBranchNameConflict)
+ return ok
+}
+
+func (err ErrBranchNameConflict) Error() string {
+ return fmt.Sprintf("branch conflicts with existing branch [name: %s]", err.BranchName)
+}
+
+// ErrTagAlreadyExists represents an error that tag with such name already exists
+type ErrTagAlreadyExists struct {
+ TagName string
+}
+
+// IsErrTagAlreadyExists checks if an error is an ErrTagAlreadyExists.
+func IsErrTagAlreadyExists(err error) bool {
+ _, ok := err.(ErrTagAlreadyExists)
+ return ok
+}
+
+func (err ErrTagAlreadyExists) Error() string {
+ return fmt.Sprintf("tag already exists [name: %s]", err.TagName)
+}
+
// __ __ ___. .__ __
// / \ / \ ____\_ |__ | |__ ____ ____ | | __
// \ \/\/ // __ \| __ \| | \ / _ \ / _ \| |/ /