Use error.New () directly to output the error message

Signed-off-by: fate-grand-order <chenjg@harmonycloud.cn>
This commit is contained in:
fate-grand-order 2017-02-10 12:32:11 +08:00
parent 696e88c813
commit af86cd4d2f
8 changed files with 13 additions and 12 deletions

View File

@ -110,7 +110,7 @@ func main() {
debugPath := context.GlobalString("debug-socket")
if debugPath == "" {
return fmt.Errorf("--debug-socket path cannot be empty")
return errors.New("--debug-socket path cannot be empty")
}
d, err := utils.CreateUnixSocket(debugPath)
if err != nil {
@ -125,7 +125,7 @@ func main() {
path := context.GlobalString("socket")
if path == "" {
return fmt.Errorf("--socket path cannot be empty")
return errors.New("--socket path cannot be empty")
}
l, err := utils.CreateUnixSocket(path)
if err != nil {

View File

@ -2,7 +2,7 @@ package main
import (
gocontext "context"
"fmt"
"errors"
"github.com/docker/containerd/api/execution"
"github.com/urfave/cli"
@ -26,7 +26,7 @@ var deleteCommand = cli.Command{
id := context.Args().First()
if id == "" {
return fmt.Errorf("container id must be provided")
return errors.New("container id must be provided")
}
pid := uint32(context.Int64("pid"))

View File

@ -2,7 +2,7 @@ package main
import (
gocontext "context"
"fmt"
"errors"
"github.com/davecgh/go-spew/spew"
"github.com/docker/containerd/api/execution"
@ -20,7 +20,7 @@ var inspectCommand = cli.Command{
}
id := context.Args().First()
if id == "" {
return fmt.Errorf("container id must be provided")
return errors.New("container id must be provided")
}
getResponse, err := executionService.GetContainer(gocontext.Background(),
&execution.GetContainerRequest{ID: id})

View File

@ -22,7 +22,7 @@ var listCommand = cli.Command{
if err != nil {
return err
}
fmt.Printf("ID\tSTATUS\tPROCS\tBUNDLE\n")
fmt.Println("ID\tSTATUS\tPROCS\tBUNDLE")
for _, c := range listResponse.Containers {
listProcResponse, err := executionService.ListProcesses(gocontext.Background(),
&execution.ListProcessesRequest{ContainerID: c.ID})

View File

@ -20,6 +20,7 @@ import (
"github.com/crosbymichael/console"
"github.com/docker/containerd/api/shim"
"github.com/urfave/cli"
"github.com/pkg/errors"
)
var fifoFlags = []cli.Flag{
@ -75,7 +76,7 @@ var shimCreateCommand = cli.Command{
Action: func(context *cli.Context) error {
id := context.Args().First()
if id == "" {
return fmt.Errorf("container id must be provided")
return errors.New("container id must be provided")
}
service, err := getShimService()
if err != nil {

2
cmd/dist/active.go vendored
View File

@ -54,7 +54,7 @@ var activeCommand = cli.Command{
}
tw := tabwriter.NewWriter(os.Stdout, 1, 8, 1, '\t', 0)
fmt.Fprintf(tw, "REF\tSIZE\tAGE\n")
fmt.Fprintln(tw, "REF\tSIZE\tAGE")
for _, active := range active {
fmt.Fprintf(tw, "%s\t%s\t%s\n",
active.Ref,

4
cmd/dist/fetch.go vendored
View File

@ -52,11 +52,11 @@ var fetchCommand = cli.Command{
}
if locator == "" {
return fmt.Errorf("containerd: remote required")
return errors.New("containerd: remote required")
}
if len(args) < 1 {
return fmt.Errorf("containerd: object required")
return errors.New("containerd: object required")
}
object := args[0]

View File

@ -60,7 +60,7 @@ func DumpDir(t *testing.T, root string) {
} else if fi.Mode().IsRegular() {
p, err := ioutil.ReadFile(path)
if err != nil {
t.Log("error reading file: %v", err)
t.Logf("error reading file: %v", err)
return nil
}