webhook.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. // WebhookNotExist represents a "WebhookNotExist" kind of error
  9. type WebhookNotExist struct {
  10. ID int64
  11. }
  12. // IsWebhookNotExist checks if an error is a WebhookNotExist
  13. func IsWebhookNotExist(err error) bool {
  14. _, ok := err.(WebhookNotExist)
  15. return ok
  16. }
  17. func (err WebhookNotExist) Error() string {
  18. return fmt.Sprintf("webhook does not exist [id: %d]", err.ID)
  19. }
  20. // HookTaskNotExist represents a "HookTaskNotExist" kind of error
  21. type HookTaskNotExist struct {
  22. HookID int64
  23. UUID string
  24. }
  25. // IsHookTaskNotExist checks if an error is a HookTaskNotExist
  26. func IsHookTaskNotExist(err error) bool {
  27. _, ok := err.(HookTaskNotExist)
  28. return ok
  29. }
  30. func (err HookTaskNotExist) Error() string {
  31. return fmt.Sprintf("hook task does not exist [hook_id: %d, uuid: %s]", err.HookID, err.UUID)
  32. }