mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Improve error management (avoid unwanted output in tests)
This commit is contained in:
parent
80f6b4587b
commit
b71b226cc1
1 changed files with 6 additions and 9 deletions
|
@ -8,7 +8,6 @@ package rcli
|
||||||
// are the usual suspects.
|
// are the usual suspects.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/term"
|
"github.com/dotcloud/docker/term"
|
||||||
|
@ -65,17 +64,15 @@ func (c *DockerLocalConn) GetOptions() *DockerConnOptions { return nil }
|
||||||
|
|
||||||
func (c *DockerLocalConn) SetOptionRawTerminal() {
|
func (c *DockerLocalConn) SetOptionRawTerminal() {
|
||||||
if state, err := SetRawTerminal(); err != nil {
|
if state, err := SetRawTerminal(); err != nil {
|
||||||
fmt.Fprintf(
|
if os.Getenv("DEBUG") != "" {
|
||||||
os.Stderr,
|
log.Printf("Can't set the terminal in raw mode: %s", err)
|
||||||
"Can't set the terminal in raw mode: %v",
|
}
|
||||||
err.Error(),
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
c.savedState = state
|
c.savedState = state
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var UnknownDockerProto = errors.New("Only TCP is actually supported by Docker at the moment")
|
var UnknownDockerProto = fmt.Errorf("Only TCP is actually supported by Docker at the moment")
|
||||||
|
|
||||||
func dialDocker(proto string, addr string) (DockerConn, error) {
|
func dialDocker(proto string, addr string) (DockerConn, error) {
|
||||||
conn, err := net.Dial(proto, addr)
|
conn, err := net.Dial(proto, addr)
|
||||||
|
@ -133,7 +130,7 @@ func LocalCall(service Service, stdin io.ReadCloser, stdout DockerConn, args ...
|
||||||
if method != nil {
|
if method != nil {
|
||||||
return method(stdin, stdout, flags.Args()[1:]...)
|
return method(stdin, stdout, flags.Args()[1:]...)
|
||||||
}
|
}
|
||||||
return errors.New("No such command: " + cmd)
|
return fmt.Errorf("No such command: %s", cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMethod(service Service, name string) Cmd {
|
func getMethod(service Service, name string) Cmd {
|
||||||
|
@ -143,7 +140,7 @@ func getMethod(service Service, name string) Cmd {
|
||||||
stdout.Write([]byte(service.Help()))
|
stdout.Write([]byte(service.Help()))
|
||||||
} else {
|
} else {
|
||||||
if method := getMethod(service, args[0]); method == nil {
|
if method := getMethod(service, args[0]); method == nil {
|
||||||
return errors.New("No such command: " + args[0])
|
return fmt.Errorf("No such command: %s", args[0])
|
||||||
} else {
|
} else {
|
||||||
method(stdin, stdout, "--help")
|
method(stdin, stdout, "--help")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue