error.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2015 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 git
  5. import (
  6. "fmt"
  7. "time"
  8. )
  9. type ErrExecTimeout struct {
  10. Duration time.Duration
  11. }
  12. func IsErrExecTimeout(err error) bool {
  13. _, ok := err.(ErrExecTimeout)
  14. return ok
  15. }
  16. func (err ErrExecTimeout) Error() string {
  17. return fmt.Sprintf("execution is timeout [duration: %v]", err.Duration)
  18. }
  19. type ErrNotExist struct {
  20. ID string
  21. RelPath string
  22. }
  23. func IsErrNotExist(err error) bool {
  24. _, ok := err.(ErrNotExist)
  25. return ok
  26. }
  27. func (err ErrNotExist) Error() string {
  28. return fmt.Sprintf("object does not exist [id: %s, rel_path: %s]", err.ID, err.RelPath)
  29. }
  30. type ErrUnsupportedVersion struct {
  31. Required string
  32. }
  33. func IsErrUnsupportedVersion(err error) bool {
  34. _, ok := err.(ErrUnsupportedVersion)
  35. return ok
  36. }
  37. func (err ErrUnsupportedVersion) Error() string {
  38. return fmt.Sprintf("Operation requires higher version [required: %s]", err.Required)
  39. }
  40. type ErrNoMergeBase struct{}
  41. func IsErrNoMergeBase(err error) bool {
  42. _, ok := err.(ErrNoMergeBase)
  43. return ok
  44. }
  45. func (err ErrNoMergeBase) Error() string {
  46. return "no merge based found"
  47. }