user.go 616 B

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