error.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Copyright 2015 The Gogs Authors. 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 models
  5. import (
  6. "fmt"
  7. )
  8. // ____ ___
  9. // | | \______ ___________
  10. // | | / ___// __ \_ __ \
  11. // | | /\___ \\ ___/| | \/
  12. // |______//____ >\___ >__|
  13. // \/ \/
  14. type ErrUserOwnRepos struct {
  15. UID int64
  16. }
  17. func IsErrUserOwnRepos(err error) bool {
  18. _, ok := err.(ErrUserOwnRepos)
  19. return ok
  20. }
  21. func (err ErrUserOwnRepos) Error() string {
  22. return fmt.Sprintf("user still has ownership of repositories: [uid: %d]", err.UID)
  23. }
  24. type ErrUserHasOrgs struct {
  25. UID int64
  26. }
  27. func IsErrUserHasOrgs(err error) bool {
  28. _, ok := err.(ErrUserHasOrgs)
  29. return ok
  30. }
  31. func (err ErrUserHasOrgs) Error() string {
  32. return fmt.Sprintf("user still has membership of organizations: [uid: %d]", err.UID)
  33. }
  34. // ________ .__ __ .__
  35. // \_____ \_______ _________ ____ |__|____________ _/ |_|__| ____ ____
  36. // / | \_ __ \/ ___\__ \ / \| \___ /\__ \\ __\ |/ _ \ / \
  37. // / | \ | \/ /_/ > __ \| | \ |/ / / __ \| | | ( <_> ) | \
  38. // \_______ /__| \___ (____ /___| /__/_____ \(____ /__| |__|\____/|___| /
  39. // \/ /_____/ \/ \/ \/ \/ \/
  40. type ErrLastOrgOwner struct {
  41. UID int64
  42. }
  43. func IsErrLastOrgOwner(err error) bool {
  44. _, ok := err.(ErrLastOrgOwner)
  45. return ok
  46. }
  47. func (err ErrLastOrgOwner) Error() string {
  48. return fmt.Sprintf("user is the last member of owner team: [uid: %d]", err.UID)
  49. }
  50. // __________ .__ __
  51. // \______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__.
  52. // | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | |
  53. // | | \ ___/| |_> > <_> )___ \| || | ( <_> ) | \/\___ |
  54. // |____|_ /\___ > __/ \____/____ >__||__| \____/|__| / ____|
  55. // \/ \/|__| \/ \/
  56. type ErrRepoNotExist struct {
  57. ID int64
  58. UID int64
  59. Name string
  60. }
  61. func IsErrRepoNotExist(err error) bool {
  62. _, ok := err.(ErrRepoNotExist)
  63. return ok
  64. }
  65. func (err ErrRepoNotExist) Error() string {
  66. return fmt.Sprintf("repository does not exist [id: %d, uid: %d, name: %s]", err.ID, err.UID, err.Name)
  67. }