优化error输出
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"git.algo.com.cn/public/saasapi"
|
||||
"git.algo.com.cn/public/saasapi/pkg/saashttp"
|
||||
@@ -22,8 +21,7 @@ func RunTaskList(args ...string) error {
|
||||
filter := paramFilterStatus(fs)
|
||||
|
||||
if err := fs.Parse(args); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "command line parse error", "err", err)
|
||||
return err
|
||||
return fmt.Errorf("Command line parse error: %w", err)
|
||||
}
|
||||
|
||||
if fs.NArg() > 0 {
|
||||
@@ -33,8 +31,7 @@ func RunTaskList(args ...string) error {
|
||||
|
||||
cfg, err := LoadConfigFile(*cfgFile)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "LoadConfigFile error", "err", err)
|
||||
return err
|
||||
return fmt.Errorf("LoadConfigFile error: %w", err)
|
||||
}
|
||||
|
||||
listTaskParams := listTaskParams{
|
||||
@@ -71,15 +68,12 @@ func doTaskList(listTaskParams listTaskParams) error {
|
||||
}
|
||||
|
||||
res, err := listTaskParams.saasHttp.TaskList(saasReq)
|
||||
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "submit List Task error", "err", err)
|
||||
return err
|
||||
return fmt.Errorf("Submit Command error: %w", err)
|
||||
}
|
||||
|
||||
if res.Code != saasapi.ErrorCode_SUCC {
|
||||
fmt.Fprintln(os.Stderr, "task list failed", "code", res.Code, "status", res.Status)
|
||||
return nil
|
||||
return fmt.Errorf("Command failed. code:%v, status:%v", res.Code, res.Status)
|
||||
}
|
||||
|
||||
taskRes := res.GetTaskListRes()
|
||||
|
||||
Reference in New Issue
Block a user