Browse code

Move errcode handling for resize upper

It'll allow to separate daemon layer more cleanly later.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>

Alexander Morozov authored on 2015/11/06 06:40:42
Showing 2 changed files
... ...
@@ -244,9 +244,6 @@ func (container *Container) ExitOnNext() {
244 244
 // Resize changes the TTY of the process running inside the container
245 245
 // to the given height and width. The container must be running.
246 246
 func (container *Container) Resize(h, w int) error {
247
-	if !container.IsRunning() {
248
-		return derr.ErrorCodeNotRunning.WithArgs(container.ID)
249
-	}
250 247
 	if err := container.command.ProcessConfig.Terminal.Resize(h, w); err != nil {
251 248
 		return err
252 249
 	}
... ...
@@ -1,5 +1,7 @@
1 1
 package daemon
2 2
 
3
+import derr "github.com/docker/docker/errors"
4
+
3 5
 // ContainerResize changes the size of the TTY of the process running
4 6
 // in the container with the given name to the given height and width.
5 7
 func (daemon *Daemon) ContainerResize(name string, height, width int) error {
... ...
@@ -8,6 +10,10 @@ func (daemon *Daemon) ContainerResize(name string, height, width int) error {
8 8
 		return err
9 9
 	}
10 10
 
11
+	if !container.IsRunning() {
12
+		return derr.ErrorCodeNotRunning.WithArgs(container.ID)
13
+	}
14
+
11 15
 	if err = container.Resize(height, width); err == nil {
12 16
 		daemon.LogContainerEvent(container, "resize")
13 17
 	}