summaryrefslogtreecommitdiffstats
path: root/models/error.go
diff options
context:
space:
mode:
authorKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2016-12-02 12:10:39 +0100
committerGitHub <noreply@github.com>2016-12-02 12:10:39 +0100
commit0f05470cb84a4dcfd00e69e5af51b4420b74e9d4 (patch)
tree9b6296dc8cfc660090fe90220397a015725e219f /models/error.go
parentd7ed78a91971260169c429f9ee47ebe8fa8f92ad (diff)
downloadgitea-0f05470cb84a4dcfd00e69e5af51b4420b74e9d4.tar.gz
gitea-0f05470cb84a4dcfd00e69e5af51b4420b74e9d4.zip
[API] Pull Requests (#248)
Diffstat (limited to 'models/error.go')
-rw-r--r--models/error.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/models/error.go b/models/error.go
index 33815cdc96..d11a9eeb1f 100644
--- a/models/error.go
+++ b/models/error.go
@@ -584,6 +584,28 @@ func (err ErrPullRequestNotExist) Error() string {
err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBarcnh, err.BaseBranch)
}
+// ErrPullRequestAlreadyExists represents a "PullRequestAlreadyExists"-error
+type ErrPullRequestAlreadyExists struct {
+ ID int64
+ IssueID int64
+ HeadRepoID int64
+ BaseRepoID int64
+ HeadBranch string
+ BaseBranch string
+}
+
+// IsErrPullRequestAlreadyExists checks if an error is a ErrPullRequestAlreadyExists.
+func IsErrPullRequestAlreadyExists(err error) bool {
+ _, ok := err.(ErrPullRequestAlreadyExists)
+ return ok
+}
+
+// Error does pretty-printing :D
+func (err ErrPullRequestAlreadyExists) Error() string {
+ return fmt.Sprintf("pull request already exists for these targets [id: %d, issue_id: %d, head_repo_id: %d, base_repo_id: %d, head_branch: %s, base_branch: %s]",
+ err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
+}
+
// _________ __
// \_ ___ \ ____ _____ _____ ____ _____/ |_
// / \ \/ / _ \ / \ / \_/ __ \ / \ __\