errors.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package plugin
  2. import "fmt"
  3. type errNotFound string
  4. func (name errNotFound) Error() string {
  5. return fmt.Sprintf("plugin %q not found", string(name))
  6. }
  7. func (errNotFound) NotFound() {}
  8. type errAmbiguous string
  9. func (name errAmbiguous) Error() string {
  10. return fmt.Sprintf("multiple plugins found for %q", string(name))
  11. }
  12. func (name errAmbiguous) InvalidParameter() {}
  13. type errDisabled string
  14. func (name errDisabled) Error() string {
  15. return fmt.Sprintf("plugin %s found but disabled", string(name))
  16. }
  17. func (name errDisabled) Conflict() {}
  18. type validationError struct {
  19. cause error
  20. }
  21. func (e validationError) Error() string {
  22. return e.cause.Error()
  23. }
  24. func (validationError) Conflict() {}
  25. func (e validationError) Cause() error {
  26. return e.cause
  27. }
  28. type systemError struct {
  29. cause error
  30. }
  31. func (e systemError) Error() string {
  32. return e.cause.Error()
  33. }
  34. func (systemError) SystemError() {}
  35. func (e systemError) Cause() error {
  36. return e.cause
  37. }
  38. type invalidFilter struct {
  39. filter string
  40. value []string
  41. }
  42. func (e invalidFilter) Error() string {
  43. msg := "Invalid filter '" + e.filter
  44. if len(e.value) > 0 {
  45. msg += fmt.Sprintf("=%s", e.value)
  46. }
  47. return msg + "'"
  48. }
  49. func (invalidFilter) InvalidParameter() {}
  50. type inUseError string
  51. func (e inUseError) Error() string {
  52. return "plugin " + string(e) + " is in use"
  53. }
  54. func (inUseError) Conflict() {}
  55. type enabledError string
  56. func (e enabledError) Error() string {
  57. return "plugin " + string(e) + " is enabled"
  58. }
  59. func (enabledError) Conflict() {}
  60. type alreadyExistsError string
  61. func (e alreadyExistsError) Error() string {
  62. return "plugin " + string(e) + " already exists"
  63. }
  64. func (alreadyExistsError) Conflict() {}