login_source.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // Copyright 2018 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. type LoginSourceNotExist struct {
  9. ID int64
  10. }
  11. func IsLoginSourceNotExist(err error) bool {
  12. _, ok := err.(LoginSourceNotExist)
  13. return ok
  14. }
  15. func (err LoginSourceNotExist) Error() string {
  16. return fmt.Sprintf("login source does not exist [id: %d]", err.ID)
  17. }
  18. type LoginSourceNotActivated struct {
  19. SourceID int64
  20. }
  21. func IsLoginSourceNotActivated(err error) bool {
  22. _, ok := err.(LoginSourceNotActivated)
  23. return ok
  24. }
  25. func (err LoginSourceNotActivated) Error() string {
  26. return fmt.Sprintf("login source is not activated [source_id: %d]", err.SourceID)
  27. }
  28. type InvalidLoginSourceType struct {
  29. Type interface{}
  30. }
  31. func IsInvalidLoginSourceType(err error) bool {
  32. _, ok := err.(InvalidLoginSourceType)
  33. return ok
  34. }
  35. func (err InvalidLoginSourceType) Error() string {
  36. return fmt.Sprintf("invalid login source type [type: %v]", err.Type)
  37. }
  38. type LoginSourceMismatch struct {
  39. Expect int64
  40. Actual int64
  41. }
  42. func IsLoginSourceMismatch(err error) bool {
  43. _, ok := err.(LoginSourceMismatch)
  44. return ok
  45. }
  46. func (err LoginSourceMismatch) Error() string {
  47. return fmt.Sprintf("login source mismatch [expect: %d, actual: %d]", err.Expect, err.Actual)
  48. }