Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
print err directly
Browse files Browse the repository at this point in the history
  • Loading branch information
GMHDBJD committed Jun 17, 2020
1 parent f222c04 commit ea58a8e
Show file tree
Hide file tree
Showing 24 changed files with 54 additions and 78 deletions.
5 changes: 2 additions & 3 deletions dm/ctl/master/check_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/pingcap/dm/checker"
"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/pkg/terror"
)

// NewCheckTaskCmd creates a CheckTask command
Expand All @@ -44,7 +43,7 @@ func checkTaskFunc(cmd *cobra.Command, _ []string) {
}
content, err := common.GetFileContent(cmd.Flags().Arg(0))
if err != nil {
common.PrintLines("get file content error:\n%v", terror.Message(err))
common.PrintLines("get file content error:\n%v", err)
return
}

Expand All @@ -57,7 +56,7 @@ func checkTaskFunc(cmd *cobra.Command, _ []string) {
Task: string(content),
})
if err != nil {
common.PrintLines("fail to check task:\n%v", terror.Message(err))
common.PrintLines("fail to check task:\n%v", err)
return
}

Expand Down
5 changes: 2 additions & 3 deletions dm/ctl/master/list_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/pkg/terror"
)

var (
Expand Down Expand Up @@ -73,7 +72,7 @@ func listMemberFunc(cmd *cobra.Command, _ []string) {

leader, master, worker, err := convertListMemberType(cmd)
if err != nil {
common.PrintLines("%s", terror.Message(err))
common.PrintLines("%v", err)
}

ctx, cancel := context.WithCancel(context.Background())
Expand All @@ -88,7 +87,7 @@ func listMemberFunc(cmd *cobra.Command, _ []string) {
})

if err != nil {
common.PrintLines("list member failed, error:\n%v", terror.Message(err))
common.PrintLines("list member failed, error:\n%v", err)
return
}
common.PrettyPrintResponse(resp)
Expand Down
3 changes: 1 addition & 2 deletions dm/ctl/master/migrate_relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/pkg/log"
"github.com/pingcap/dm/pkg/terror"
)

// NewMigrateRelayCmd creates a MigrateRelay command
Expand All @@ -49,7 +48,7 @@ func migrateRelayFunc(cmd *cobra.Command, _ []string) {
binlogName := cmd.Flags().Arg(1)
binlogPos, err := strconv.Atoi(cmd.Flags().Arg(2))
if err != nil {
common.PrintLines(terror.Message(err))
common.PrintLines("%v", err)
}

ctx, cancel := context.WithCancel(context.Background())
Expand Down
7 changes: 3 additions & 4 deletions dm/ctl/master/offline_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (

"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/pkg/terror"

"github.com/pingcap/errors"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -66,12 +65,12 @@ func offlineMemberFunc(cmd *cobra.Command, _ []string) {

offlineType, err := convertOfflineMemberType(cmd)
if err != nil {
common.PrintLines("get offline type failed, error:\n%v", terror.Message(err))
common.PrintLines("get offline type failed, error:\n%v", err)
return
}
name, err := cmd.Flags().GetString("name")
if err != nil {
common.PrintLines("get offline name failed, error:\n%v", terror.Message(err))
common.PrintLines("get offline name failed, error:\n%v", err)
return
} else if name == "" {
common.PrintLines("a member name must be specified")
Expand All @@ -86,7 +85,7 @@ func offlineMemberFunc(cmd *cobra.Command, _ []string) {
Name: name,
})
if err != nil {
common.PrintLines("offline member failed, error:\n%v", terror.Message(err))
common.PrintLines("offline member failed, error:\n%v", err)
return
}
if !resp.Result {
Expand Down
3 changes: 1 addition & 2 deletions dm/ctl/master/operate_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/pkg/terror"
)

// NewOperateLeaderCmd creates a OperateLeader command
Expand Down Expand Up @@ -70,7 +69,7 @@ func operateLeaderFunc(cmd *cobra.Command, _ []string) {
Op: op,
})
if err != nil {
common.PrintLines("fail to operate leader:\n%v", terror.Message(err))
common.PrintLines("fail to operate leader:\n%v", err)
return
}

Expand Down
5 changes: 2 additions & 3 deletions dm/ctl/master/operate_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (

"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/pkg/terror"

"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -59,7 +58,7 @@ func operateSourceFunc(cmd *cobra.Command, _ []string) {
configFile := cmd.Flags().Arg(1)
content, err := common.GetFileContent(configFile)
if err != nil {
common.PrintLines("get file content error:\n%v", terror.Message(err))
common.PrintLines("get file content error:\n%v", err)
return
}
ctx, cancel := context.WithCancel(context.Background())
Expand All @@ -77,7 +76,7 @@ func operateSourceFunc(cmd *cobra.Command, _ []string) {
Op: op,
})
if err != nil {
common.PrintLines("can not update task:\n%v", terror.Message(err))
common.PrintLines("can not update task:\n%v", err)
return
}

Expand Down
5 changes: 2 additions & 3 deletions dm/ctl/master/pause_relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/pkg/terror"
)

// NewPauseRelayCmd creates a PauseRelay command
Expand All @@ -44,7 +43,7 @@ func pauseRelayFunc(cmd *cobra.Command, _ []string) {

sources, err := common.GetSourceArgs(cmd)
if err != nil {
common.PrintLines("%s", terror.Message(err))
common.PrintLines("%v", err)
return
}
if len(sources) == 0 {
Expand All @@ -54,7 +53,7 @@ func pauseRelayFunc(cmd *cobra.Command, _ []string) {

resp, err := common.OperateRelay(pb.RelayOp_PauseRelay, sources)
if err != nil {
common.PrintLines("can not pause relay unit:\n%v", terror.Message(err))
common.PrintLines("can not pause relay unit:\n%v", err)
return
}

Expand Down
5 changes: 2 additions & 3 deletions dm/ctl/master/pause_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (

"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/pkg/terror"
)

// NewPauseTaskCmd creates a PauseTask command
Expand All @@ -44,13 +43,13 @@ func pauseTaskFunc(cmd *cobra.Command, _ []string) {

sources, err := common.GetSourceArgs(cmd)
if err != nil {
common.PrintLines("%s", terror.Message(err))
common.PrintLines("%v", err)
return
}

resp, err := common.OperateTask(pb.TaskOp_Pause, name, sources)
if err != nil {
common.PrintLines("can not pause task %s:\n%v", name, terror.Message(err))
common.PrintLines("can not pause task %s:\n%v", name, err)
return
}

Expand Down
5 changes: 2 additions & 3 deletions dm/ctl/master/purge_relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/pingcap/dm/dm/command"
"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/pkg/terror"
)

var (
Expand Down Expand Up @@ -64,7 +63,7 @@ func purgeRelayFunc(cmd *cobra.Command, _ []string) {

sources, err := common.GetSourceArgs(cmd)
if err != nil {
fmt.Println(terror.Message(err))
common.PrintLines("%v", err)
return
}
if len(sources) == 0 {
Expand Down Expand Up @@ -146,7 +145,7 @@ func purgeRelayFunc(cmd *cobra.Command, _ []string) {
SubDir: subDir,
})
if err != nil {
common.PrintLines("can not purge relay log files: \n%s", terror.Message(err))
common.PrintLines("can not purge relay log files: \n%v", err)
return
}

Expand Down
5 changes: 2 additions & 3 deletions dm/ctl/master/query_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (

"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/pkg/terror"

"github.com/spf13/cobra"
)
Expand All @@ -45,7 +44,7 @@ func queryErrorFunc(cmd *cobra.Command, _ []string) {

sources, err := common.GetSourceArgs(cmd)
if err != nil {
common.PrintLines("%s", terror.Message(err))
common.PrintLines("%v", err)
return
}

Expand All @@ -64,7 +63,7 @@ func queryErrorFunc(cmd *cobra.Command, _ []string) {
if len(sources) > 0 {
common.PrintLines("sources: %v", sources)
}
common.PrintLines("error: %s", terror.Message(err))
common.PrintLines("error: %v", err)
return
}

Expand Down
7 changes: 3 additions & 4 deletions dm/ctl/master/query_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/pkg/terror"
)

const stageError = "Error"
Expand Down Expand Up @@ -61,7 +60,7 @@ func queryStatusFunc(cmd *cobra.Command, _ []string) {

sources, err := common.GetSourceArgs(cmd)
if err != nil {
common.PrintLines("%s", terror.Message(err))
common.PrintLines("%v", err)
return
}

Expand All @@ -73,13 +72,13 @@ func queryStatusFunc(cmd *cobra.Command, _ []string) {
Sources: sources,
})
if err != nil {
common.PrintLines("can not query %s task's status(in sources %v):\n%s", taskName, sources, terror.Message(err))
common.PrintLines("can not query %s task's status(in sources %v):\n%v", taskName, sources, err)
return
}

more, err := cmd.Flags().GetBool("more")
if err != nil {
common.PrintLines("%s", terror.Message(err))
common.PrintLines("%v", err)
return
}

Expand Down
5 changes: 2 additions & 3 deletions dm/ctl/master/resume_relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/pkg/terror"
)

// NewResumeRelayCmd creates a ResumeRelay command
Expand All @@ -44,7 +43,7 @@ func resumeRelayFunc(cmd *cobra.Command, _ []string) {

sources, err := common.GetSourceArgs(cmd)
if err != nil {
common.PrintLines("%s", terror.Message(err))
common.PrintLines("%v", err)
return
}
if len(sources) == 0 {
Expand All @@ -54,7 +53,7 @@ func resumeRelayFunc(cmd *cobra.Command, _ []string) {

resp, err := common.OperateRelay(pb.RelayOp_ResumeRelay, sources)
if err != nil {
common.PrintLines("can not resume relay unit:\n%v", terror.Message(err))
common.PrintLines("can not resume relay unit:\n%v", err)
return
}

Expand Down
5 changes: 2 additions & 3 deletions dm/ctl/master/resume_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (

"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/pkg/terror"
)

// NewResumeTaskCmd creates a ResumeTask command
Expand All @@ -44,13 +43,13 @@ func resumeTaskFunc(cmd *cobra.Command, _ []string) {

sources, err := common.GetSourceArgs(cmd)
if err != nil {
common.PrintLines("%s", terror.Message(err))
common.PrintLines("%v", err)
return
}

resp, err := common.OperateTask(pb.TaskOp_Resume, name, sources)
if err != nil {
common.PrintLines("can not resume task %s:\n%v", name, terror.Message(err))
common.PrintLines("can not resume task %s:\n%v", name, err)
return
}

Expand Down
5 changes: 2 additions & 3 deletions dm/ctl/master/show_ddl_locks.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (

"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/pkg/terror"

"github.com/spf13/cobra"
)
Expand All @@ -45,7 +44,7 @@ func showDDLLocksFunc(cmd *cobra.Command, _ []string) {

sources, err := common.GetSourceArgs(cmd)
if err != nil {
common.PrintLines("%s", terror.Message(err))
common.PrintLines("%v", err)
return
}

Expand All @@ -57,7 +56,7 @@ func showDDLLocksFunc(cmd *cobra.Command, _ []string) {
Sources: sources,
})
if err != nil {
common.PrintLines("can not show DDL locks for task %s and sources %v:\n%s", taskName, sources, terror.Message(err))
common.PrintLines("can not show DDL locks for task %s and sources %v:\n%s", taskName, sources, err)
return
}

Expand Down
9 changes: 4 additions & 5 deletions dm/ctl/master/sql_inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/pingcap/dm/dm/ctl/common"
"github.com/pingcap/dm/dm/pb"
"github.com/pingcap/dm/pkg/terror"
)

// NewSQLInjectCmd creates a SQLInject command
Expand All @@ -45,7 +44,7 @@ func sqlInjectFunc(cmd *cobra.Command, _ []string) {

sources, err := common.GetSourceArgs(cmd)
if err != nil {
common.PrintLines("%s", terror.Message(err))
common.PrintLines("%v", err)
return
}
if len(sources) != 1 {
Expand All @@ -62,13 +61,13 @@ func sqlInjectFunc(cmd *cobra.Command, _ []string) {
extraArgs := cmd.Flags().Args()[1:]
realSQLs, err := common.ExtractSQLsFromArgs(extraArgs)
if err != nil {
common.PrintLines("check sqls err %s", terror.Message(err))
common.PrintLines("check sqls err %v", err)
return
}
for _, sql := range realSQLs {
isDDL, err2 := common.IsDDL(sql)
if err2 != nil {
common.PrintLines("check sql err %s", terror.Message(err2))
common.PrintLines("check sql err %v", err2)
return
}
if !isDDL {
Expand All @@ -87,7 +86,7 @@ func sqlInjectFunc(cmd *cobra.Command, _ []string) {
Source: sources[0],
})
if err != nil {
common.PrintLines("can not inject sql:\n%v", terror.Message(err))
common.PrintLines("can not inject sql:\n%v", err)
return
}

Expand Down
Loading

0 comments on commit ea58a8e

Please sign in to comment.