You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

error.go 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2022 Gitea. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package foreignreference
  5. import (
  6. "fmt"
  7. )
  8. // ErrLocalIndexNotExist represents a "LocalIndexNotExist" kind of error.
  9. type ErrLocalIndexNotExist struct {
  10. RepoID int64
  11. ForeignIndex int64
  12. Type string
  13. }
  14. // ErrLocalIndexNotExist checks if an error is a ErrLocalIndexNotExist.
  15. func IsErrLocalIndexNotExist(err error) bool {
  16. _, ok := err.(ErrLocalIndexNotExist)
  17. return ok
  18. }
  19. func (err ErrLocalIndexNotExist) Error() string {
  20. return fmt.Sprintf("repository %d has no LocalIndex for ForeignIndex %d of type %s", err.RepoID, err.ForeignIndex, err.Type)
  21. }
  22. // ErrForeignIndexNotExist represents a "ForeignIndexNotExist" kind of error.
  23. type ErrForeignIndexNotExist struct {
  24. RepoID int64
  25. LocalIndex int64
  26. Type string
  27. }
  28. // ErrForeignIndexNotExist checks if an error is a ErrForeignIndexNotExist.
  29. func IsErrForeignIndexNotExist(err error) bool {
  30. _, ok := err.(ErrForeignIndexNotExist)
  31. return ok
  32. }
  33. func (err ErrForeignIndexNotExist) Error() string {
  34. return fmt.Sprintf("repository %d has no ForeignIndex for LocalIndex %d of type %s", err.RepoID, err.LocalIndex, err.Type)
  35. }