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

Commit

Permalink
error_message: more friendly error message #711 (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
GMHDBJD authored Jul 15, 2020
1 parent a1b390c commit becb317
Show file tree
Hide file tree
Showing 31 changed files with 855 additions and 1,112 deletions.
8 changes: 7 additions & 1 deletion _utils/terror_gen/checker_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ func genErrors() {
w := bufio.NewWriter(f)
for _, item := range errors {
s := strings.SplitN(item.err.Error(), " ", 2)
w.WriteString(fmt.Sprintf("%s,%s \"%s\"\n", item.name, s[0], strings.ReplaceAll(s[1], "\n", "\\n")))
if len(s) > 1 {
// errName,[code:class:scope:level], "Message, RawCause, Workaround"
w.WriteString(fmt.Sprintf("%s,%s \"%s\"\n", item.name, s[0], strings.ReplaceAll(s[1], "\n", "\\n")))
} else {
// errName,[code:class:scope:level]
w.WriteString(fmt.Sprintf("%s,%s\n", item.name, s[0]))
}
}
w.Flush()
}
Expand Down
907 changes: 454 additions & 453 deletions _utils/terror_gen/errors_release.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ func (c *Checker) Process(ctx context.Context, pr chan pb.ProcessResult) {
errs := make([]*pb.ProcessError, 0, 1)
result, err := check.Do(cctx, c.checkList)
if err != nil {
errs = append(errs, unit.NewProcessError(pb.ErrorType_CheckFailed, err))
errs = append(errs, unit.NewProcessError(err))
} else if !result.Summary.Passed {
errs = append(errs, unit.NewProcessError(pb.ErrorType_CheckFailed, errors.New("check was failed, please see detail")))
errs = append(errs, unit.NewProcessError(errors.New("check was failed, please see detail")))

// remove success result if not pass
results := result.Results[:0]
Expand Down
2 changes: 1 addition & 1 deletion checker/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func CheckSyncConfig(ctx context.Context, cfgs []*config.SubTaskConfig) error {
r := <-pr
// we only want first error
if len(r.Errors) > 0 {
return terror.ErrTaskCheckSyncConfigError.Generate(ErrorMsgHeader, r.Errors[0].Msg, string(r.Detail))
return terror.ErrTaskCheckSyncConfigError.Generate(ErrorMsgHeader, r.Errors[0].Message, string(r.Detail))
}
}

Expand Down
10 changes: 5 additions & 5 deletions dm/config/subtask_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,39 +98,39 @@ func (t *testConfig) TestSubTaskAdjustFail(c *C) {
cfg.Name = ""
return cfg
},
"\\[.*\\], msg: 'task name should not be empty'.*",
"\\[.*\\], Message: task name should not be empty.*",
},
{
func() *SubTaskConfig {
cfg := newSubTaskConfig()
cfg.SourceID = ""
return cfg
},
"\\[.*\\], msg: 'empty source-id not valid'.*",
"\\[.*\\], Message: empty source-id not valid.*",
},
{
func() *SubTaskConfig {
cfg := newSubTaskConfig()
cfg.SourceID = "source-id-length-more-than-thirty-two"
return cfg
},
"\\[.*\\], msg: 'too long source-id not valid'.*",
"\\[.*\\], Message: too long source-id not valid.*",
},
{
func() *SubTaskConfig {
cfg := newSubTaskConfig()
cfg.OnlineDDLScheme = "rtc"
return cfg
},
"\\[.*\\], msg: 'online scheme rtc not supported'.*",
"\\[.*\\], Message: online scheme rtc not supported.*",
},
{
func() *SubTaskConfig {
cfg := newSubTaskConfig()
cfg.Timezone = "my-house"
return cfg
},
"\\[.*\\], msg: 'invalid timezone string: my-house:.*",
"\\[.*\\], Message: invalid timezone string: my-house.*",
},
}

Expand Down
6 changes: 3 additions & 3 deletions dm/ctl/master/query_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (t *testCtlMaster) TestWrapTaskResult(c *check.C) {
Name: "test",
Stage: pb.Stage_Paused,
Result: &pb.ProcessResult{
Errors: []*pb.ProcessError{{Type: pb.ErrorType_ExecSQL}},
Errors: []*pb.ProcessError{{}},
},
}},
},
Expand All @@ -95,7 +95,7 @@ func (t *testCtlMaster) TestWrapTaskResult(c *check.C) {
resp.Workers[0].RelayStatus = &pb.RelayStatus{
Stage: pb.Stage_Paused,
Result: &pb.ProcessResult{
Errors: []*pb.ProcessError{{Type: pb.ErrorType_CheckFailed}},
Errors: []*pb.ProcessError{{}},
}}
expectedResult[0].TaskStatus = stageError + " - Relay status is " + stageError + extraInfo
generateAndCheckTaskResult(c, resp, expectedResult)
Expand Down Expand Up @@ -132,7 +132,7 @@ func (t *testCtlMaster) TestWrapTaskResult(c *check.C) {
Name: "test2",
Stage: pb.Stage_Paused,
Result: &pb.ProcessResult{
Errors: []*pb.ProcessError{{Type: pb.ErrorType_ExecSQL}},
Errors: []*pb.ProcessError{{}},
},
}},
})
Expand Down
Loading

0 comments on commit becb317

Please sign in to comment.