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

error_message: more friendly error message #771

Merged
merged 17 commits into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion _utils/terror_gen/checker_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,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]))
}

body := tomlErrorBody{
Message: item.err.Message(),
Expand Down
907 changes: 454 additions & 453 deletions _utils/terror_gen/errors_release.txt

Large diffs are not rendered by default.

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
12 changes: 6 additions & 6 deletions dm/config/subtask_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,47 +99,47 @@ 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.ShardMode = "invalid-shard-mode"
return cfg
},
"\\[.*\\], msg: 'shard mode invalid-shard-mode not supported'.*",
"\\[.*\\], Message: shard mode invalid-shard-mode not supported.*",
},
{
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{{Error: &pb.TError{}}},
Errors: []*pb.ProcessError{{}},
},
}},
},
Expand All @@ -95,7 +95,7 @@ func (t *testCtlMaster) TestWrapTaskResult(c *check.C) {
resp.Sources[0].SourceStatus.RelayStatus = &pb.RelayStatus{
Stage: pb.Stage_Paused,
Result: &pb.ProcessResult{
Errors: []*pb.ProcessError{{Error: &pb.TError{}}},
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{{Error: &pb.TError{}}},
Errors: []*pb.ProcessError{{}},
},
}},
})
Expand Down
Loading