user.go 621 B

123456789101112131415161718192021222324252627282930313233
  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 (
  6. "fmt"
  7. )
  8. type EmptyName struct{}
  9. func IsEmptyName(err error) bool {
  10. _, ok := err.(EmptyName)
  11. return ok
  12. }
  13. func (err EmptyName) Error() string {
  14. return "empty name"
  15. }
  16. type UserNotKeyOwner struct {
  17. KeyID int64
  18. }
  19. func IsUserNotKeyOwner(err error) bool {
  20. _, ok := err.(UserNotKeyOwner)
  21. return ok
  22. }
  23. func (err UserNotKeyOwner) Error() string {
  24. return fmt.Sprintf("user is not the owner of public key [key_id: %d]", err.KeyID)
  25. }