1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

client.StatusError don't be returned as a pointer

closes #12373

1. remove & from client.StatusError
2. remove * from Error method

Signed-off-by: Deshi Xiao <xiaods@gmail.com>
This commit is contained in:
Deshi Xiao 2015-04-15 16:57:52 +08:00
parent da697dbed6
commit bae3023eef
8 changed files with 10 additions and 10 deletions

View file

@ -80,7 +80,7 @@ func (cli *DockerCli) CmdAttach(args ...string) error {
return err
}
if status != 0 {
return &StatusError{StatusCode: status}
return StatusError{StatusCode: status}
}
return nil

View file

@ -302,7 +302,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
if jerr.Code == 0 {
jerr.Code = 1
}
return &StatusError{Status: jerr.Message, StatusCode: jerr.Code}
return StatusError{Status: jerr.Message, StatusCode: jerr.Code}
}
return err
}

View file

@ -12,6 +12,6 @@ type StatusError struct {
StatusCode int
}
func (e *StatusError) Error() string {
func (e StatusError) Error() string {
return fmt.Sprintf("Status: %s, Code: %d", e.Status, e.StatusCode)
}

View file

@ -20,7 +20,7 @@ func (cli *DockerCli) CmdExec(args ...string) error {
execConfig, err := runconfig.ParseExec(cmd, args)
// just in case the ParseExec does not exit
if execConfig.Container == "" || err != nil {
return &StatusError{StatusCode: 1}
return StatusError{StatusCode: 1}
}
stream, _, err := cli.call("POST", "/containers/"+execConfig.Container+"/exec", execConfig, nil)
@ -121,7 +121,7 @@ func (cli *DockerCli) CmdExec(args ...string) error {
}
if status != 0 {
return &StatusError{StatusCode: status}
return StatusError{StatusCode: status}
}
return nil

View file

@ -26,7 +26,7 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
var err error
if tmpl, err = template.New("").Funcs(funcMap).Parse(*tmplStr); err != nil {
fmt.Fprintf(cli.err, "Template parsing error: %v\n", err)
return &StatusError{StatusCode: 64,
return StatusError{StatusCode: 64,
Status: "Template parsing error: " + err.Error()}
}
}
@ -85,7 +85,7 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
}
if status != 0 {
return &StatusError{StatusCode: status}
return StatusError{StatusCode: status}
}
return nil
}

View file

@ -241,7 +241,7 @@ func (cli *DockerCli) CmdRun(args ...string) error {
}
}
if status != 0 {
return &StatusError{StatusCode: status}
return StatusError{StatusCode: status}
}
return nil
}

View file

@ -155,7 +155,7 @@ func (cli *DockerCli) CmdStart(args ...string) error {
return err
}
if status != 0 {
return &StatusError{StatusCode: status}
return StatusError{StatusCode: status}
}
}
return nil

View file

@ -135,7 +135,7 @@ func main() {
}
if err := cli.Cmd(flag.Args()...); err != nil {
if sterr, ok := err.(*client.StatusError); ok {
if sterr, ok := err.(client.StatusError); ok {
if sterr.Status != "" {
logrus.Println(sterr.Status)
}