login_source.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2017 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 errors
  5. import "fmt"
  6. type LoginSourceNotExist struct {
  7. ID int64
  8. }
  9. func IsLoginSourceNotExist(err error) bool {
  10. _, ok := err.(LoginSourceNotExist)
  11. return ok
  12. }
  13. func (err LoginSourceNotExist) Error() string {
  14. return fmt.Sprintf("login source does not exist [id: %d]", err.ID)
  15. }
  16. type LoginSourceNotActivated struct {
  17. SourceID int64
  18. }
  19. func IsLoginSourceNotActivated(err error) bool {
  20. _, ok := err.(LoginSourceNotActivated)
  21. return ok
  22. }
  23. func (err LoginSourceNotActivated) Error() string {
  24. return fmt.Sprintf("login source is not activated [source_id: %d]", err.SourceID)
  25. }
  26. type InvalidLoginSourceType struct {
  27. Type interface{}
  28. }
  29. func IsInvalidLoginSourceType(err error) bool {
  30. _, ok := err.(InvalidLoginSourceType)
  31. return ok
  32. }
  33. func (err InvalidLoginSourceType) Error() string {
  34. return fmt.Sprintf("invalid login source type [type: %v]", err.Type)
  35. }