errors.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package daemon
  2. import (
  3. "fmt"
  4. "github.com/docker/docker/api/errors"
  5. )
  6. func (d *Daemon) imageNotExistToErrcode(err error) error {
  7. if dne, isDNE := err.(ErrImageDoesNotExist); isDNE {
  8. return errors.NewRequestNotFoundError(dne)
  9. }
  10. return err
  11. }
  12. type errNotRunning struct {
  13. containerID string
  14. }
  15. func (e errNotRunning) Error() string {
  16. return fmt.Sprintf("Container %s is not running", e.containerID)
  17. }
  18. func (e errNotRunning) ContainerIsRunning() bool {
  19. return false
  20. }
  21. func errContainerIsRestarting(containerID string) error {
  22. err := fmt.Errorf("Container %s is restarting, wait until the container is running", containerID)
  23. return errors.NewRequestConflictError(err)
  24. }
  25. func errExecNotFound(id string) error {
  26. err := fmt.Errorf("No such exec instance '%s' found in daemon", id)
  27. return errors.NewRequestNotFoundError(err)
  28. }
  29. func errExecPaused(id string) error {
  30. err := fmt.Errorf("Container %s is paused, unpause the container before exec", id)
  31. return errors.NewRequestConflictError(err)
  32. }
  33. type errNotFound struct {
  34. containerID string
  35. }
  36. func (e errNotFound) Error() string {
  37. return fmt.Sprintf("Container %s is not found", e.containerID)
  38. }
  39. func (e errNotFound) ContainerNotFound() bool {
  40. return true
  41. }