aboutsummaryrefslogtreecommitdiffstats
path: root/models/error.go
diff options
context:
space:
mode:
authorlstahlman <luke.stahlman@gmail.com>2016-08-03 09:24:16 -0700
committer无闻 <u@gogs.io>2016-08-03 09:24:16 -0700
commit2eeb0ec9b032ea02d315922feb762637ecd9ddc8 (patch)
tree7d82858e07e185939b34f372689208bbe4ee959d /models/error.go
parentb1133c99348c332df4cede25af9093aa0cfd302b (diff)
downloadgitea-2eeb0ec9b032ea02d315922feb762637ecd9ddc8.tar.gz
gitea-2eeb0ec9b032ea02d315922feb762637ecd9ddc8.zip
Additional API support for labels (#3290)
* Add API support for labels. * Error handling for adding/replacing multiple issue labels * Revisions to function names and error handling. Use issue.ClearLabels in replace/clear functions * Additional code cleanup
Diffstat (limited to 'models/error.go')
-rw-r--r--models/error.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/models/error.go b/models/error.go
index a6cf31218c..a6c54ab088 100644
--- a/models/error.go
+++ b/models/error.go
@@ -5,6 +5,7 @@
package models
import (
+ "bytes"
"fmt"
)
@@ -34,6 +35,30 @@ func (err ErrNamePatternNotAllowed) Error() string {
return fmt.Sprintf("name pattern is not allowed [pattern: %s]", err.Pattern)
}
+type ErrMultipleErrors struct {
+ Errors []error
+}
+
+func IsErrMultipleErrors(err error) bool {
+ _, ok := err.(ErrMultipleErrors)
+ return ok
+}
+
+func (err ErrMultipleErrors) Error() string {
+ var message bytes.Buffer
+
+ message.WriteString("Multiple errors encountered: ")
+
+ for i := range err.Errors {
+ message.WriteString(err.Errors[i].Error())
+ if i < len(err.Errors)-1 {
+ message.WriteString("; ")
+ }
+ }
+
+ return message.String()
+}
+
// ____ ___
// | | \______ ___________
// | | / ___// __ \_ __ \
@@ -545,6 +570,20 @@ func (err ErrLabelNotExist) Error() string {
return fmt.Sprintf("label does not exist [id: %d]", err.ID)
}
+type ErrLabelNotValidForRepository struct {
+ ID int64
+ RepoID int64
+}
+
+func IsErrLabelNotValidForRepository(err error) bool {
+ _, ok := err.(ErrLabelNotValidForRepository)
+ return ok
+}
+
+func (err ErrLabelNotValidForRepository) Error() string {
+ return fmt.Sprintf("label is not valid for repository [label_id: %d, repo_id: %d]", err.ID, err.RepoID)
+}
+
// _____ .__.__ __
// / \ |__| | ____ _______/ |_ ____ ____ ____
// / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \