1
0

repo.go 814 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package errors
  2. import (
  3. "fmt"
  4. )
  5. type InvalidRepoReference struct {
  6. Ref string
  7. }
  8. func IsInvalidRepoReference(err error) bool {
  9. _, ok := err.(InvalidRepoReference)
  10. return ok
  11. }
  12. func (err InvalidRepoReference) Error() string {
  13. return fmt.Sprintf("invalid repository reference [ref: %s]", err.Ref)
  14. }
  15. type MirrorNotExist struct {
  16. RepoID int64
  17. }
  18. func IsMirrorNotExist(err error) bool {
  19. _, ok := err.(MirrorNotExist)
  20. return ok
  21. }
  22. func (err MirrorNotExist) Error() string {
  23. return fmt.Sprintf("mirror does not exist [repo_id: %d]", err.RepoID)
  24. }
  25. type BranchAlreadyExists struct {
  26. Name string
  27. }
  28. func IsBranchAlreadyExists(err error) bool {
  29. _, ok := err.(BranchAlreadyExists)
  30. return ok
  31. }
  32. func (err BranchAlreadyExists) Error() string {
  33. return fmt.Sprintf("branch already exists [name: %s]", err.Name)
  34. }