Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using standard error code to replace terror #982

Merged
merged 12 commits into from
Sep 8, 2020
Merged

Conversation

imtbkcat
Copy link

What problem does this PR solve?

According to RFC, TiDB need to adjust error format and using standard error to replace terror. The standard error has been implemented in https://github.com/pingcap/errors/tree/standard-error

What is changed and how it works?

Since standard error is very similar with terror. We can change very few api to replace the terror. Just rename terror.Error with errors.Error

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change
  • Has exported variable/fields change

Side effects

  • Increased code complexity
  • Breaking backward compatibility

Related changes

  • None

terror/terror.go Outdated
Comment on lines 143 to 147
var rfcCode = fmt.Sprintf("%s:%d", errClass2Desc[ec], code)
err := errors.Normalize(message, errors.MySQLErrorCode(int(code)), errors.RFCCodeText(rfcCode))
errCodeMap[code] = err
tags := strings.Split(rfcCode, ":")
class := tags[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var rfcCode = fmt.Sprintf("%s:%d", errClass2Desc[ec], code)
err := errors.Normalize(message, errors.MySQLErrorCode(int(code)), errors.RFCCodeText(rfcCode))
errCodeMap[code] = err
tags := strings.Split(rfcCode, ":")
class := tags[0]
class := errClass2Desc[ec]
rfcCode := fmt.Sprintf("%s:%d", class, code)
err := errors.Normalize(message, errors.MySQLErrorCode(int(code)), errors.RFCCodeText(rfcCode))
errCodeMap[code] = err

terror/terror.go Outdated Show resolved Hide resolved
terror/terror.go Outdated Show resolved Hide resolved
terror/terror.go Outdated Show resolved Hide resolved
Copy link
Contributor

@lonng lonng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM

@imtbkcat
Copy link
Author

PTAL @kennytm @lonng

Copy link
Contributor

@lonng lonng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-srebot
Copy link
Contributor

@lonng,Thanks for your review. However, LGTM is restricted to Reviewers or higher roles.See the corresponding SIG page for more information. Related SIGs: ddl(slack).

@imtbkcat
Copy link
Author

imtbkcat commented Sep 3, 2020

PTAL @kennytm

Copy link
Contributor

@kennytm kennytm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ti-srebot ti-srebot removed the status/LGT1 LGT1 label Sep 8, 2020
@imtbkcat imtbkcat merged commit 8157d63 into pingcap:master Sep 8, 2020
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 failed

imtbkcat pushed a commit to imtbkcat/parser that referenced this pull request Sep 8, 2020
imtbkcat pushed a commit that referenced this pull request Sep 11, 2020
imtbkcat pushed a commit to imtbkcat/parser that referenced this pull request Sep 18, 2020
tiancaiamao pushed a commit to tiancaiamao/parser that referenced this pull request Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants