user_mail.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2015 - Present, The Gogs Authors. All rights reserved.
  2. // Copyright 2018 - Present, 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. // EmailNotFound represents a "EmailNotFound" kind of error
  9. type EmailNotFound struct {
  10. Email string
  11. }
  12. // IsEmailNotFound checks if an error is a EmailNotFound
  13. func IsEmailNotFound(err error) bool {
  14. _, ok := err.(EmailNotFound)
  15. return ok
  16. }
  17. func (err EmailNotFound) Error() string {
  18. return fmt.Sprintf("email is not found [email: %s]", err.Email)
  19. }
  20. // EmailNotVerified represents a "EmailNotVerified" kind of error
  21. type EmailNotVerified struct {
  22. Email string
  23. }
  24. // IsEmailNotVerified checks if an error is a EmailNotVerified
  25. func IsEmailNotVerified(err error) bool {
  26. _, ok := err.(EmailNotVerified)
  27. return ok
  28. }
  29. func (err EmailNotVerified) Error() string {
  30. return fmt.Sprintf("email has not been verified [email: %s]", err.Email)
  31. }