issue.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2015 - Present, The Gogs Authors. All rights reserved.
  2. // Copyright 2018 - Present, Gitote. All rights reserved.
  3. //
  4. // This source code is licensed under the MIT license found in the
  5. // LICENSE file in the root directory of this source tree.
  6. package errors
  7. import "fmt"
  8. // IssueNotExist represents issue not exist
  9. type IssueNotExist struct {
  10. ID int64
  11. RepoID int64
  12. Index int64
  13. }
  14. // IsIssueNotExist returns true if issue not exist
  15. func IsIssueNotExist(err error) bool {
  16. _, ok := err.(IssueNotExist)
  17. return ok
  18. }
  19. func (err IssueNotExist) Error() string {
  20. return fmt.Sprintf("issue does not exist [id: %d, repo_id: %d, index: %d]", err.ID, err.RepoID, err.Index)
  21. }
  22. // InvalidIssueReference represents invalid issue reference
  23. type InvalidIssueReference struct {
  24. Ref string
  25. }
  26. // IsInvalidIssueReference returns true if invalid issue reference
  27. func IsInvalidIssueReference(err error) bool {
  28. _, ok := err.(InvalidIssueReference)
  29. return ok
  30. }
  31. func (err InvalidIssueReference) Error() string {
  32. return fmt.Sprintf("invalid issue reference [ref: %s]", err.Ref)
  33. }