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

make tidb adaptor in errors. #2

Merged
merged 21 commits into from
Sep 7, 2018
Merged

make tidb adaptor in errors. #2

merged 21 commits into from
Sep 7, 2018

Conversation

lysu
Copy link
Collaborator

@lysu lysu commented Sep 5, 2018

What have you changed? (mandatory)

adaptor pkg/errors to tidb/tidb-operator, mainly worked by @gregwebs

ref issue

#1
https://github.com/lysu/errors/pull/2
pingcap/tidb-operator#80
pingcap/tidb#7151

What is the type of the changes? (mandatory)

  • Improvement (non-breaking change which is an improvement to an existing feature)

How has this PR been tested? (mandatory)

  • unit tests
  • integration tests

Does this PR affect documentation (docs/docs-cn) update? (mandatory)

no

Does this PR affect tidb-ansible update? (mandatory)

no

Does this PR need to be added to the release notes? (mandatory)

no

Refer to a related PR or issue link (optional)


This change is Reviewable

format_test.go Outdated
testGenericRecursive(t, err, want, wrappers, 3)
}
}
//func TestFormatGeneric(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Why comment out this test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

because we change the logic, N x N combination testcase is no longer suitable.

Copy link
Member

Choose a reason for hiding this comment

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

We can use a block comment /* */ to reduce the changed lines.

errors.go Outdated
@@ -115,6 +115,10 @@ func Errorf(format string, args ...interface{}) error {
}
}

type withStackAware interface {
Copy link
Member

Choose a reason for hiding this comment

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

Why not hasStackAware?

errors.go Outdated
@@ -119,6 +119,14 @@ type withStackAware interface {
hasStack() bool
}

func hasStack(err error) bool {
Copy link
Member

Choose a reason for hiding this comment

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

rename to errHasStack to avoid name conflict?

@coocood
Copy link
Member

coocood commented Sep 5, 2018

LGTM

@gregwebs
Copy link

gregwebs commented Sep 5, 2018

I have a PR to this branch: https://github.com/lysu/errors/pull/2

@coocood
Copy link
Member

coocood commented Sep 6, 2018

LGTM

@lysu
Copy link
Collaborator Author

lysu commented Sep 6, 2018

I have no write access, need a merge~ then I will finish TiDB's PR, thx @coocood @gregwebs

@gregwebs
Copy link

gregwebs commented Sep 6, 2018

I don't have write access.

@coocood
Copy link
Member

coocood commented Sep 6, 2018

@gregwebs @lysu
We need another LGTM to merge

errors.go Outdated
// StackTrace() errors.StackTrace
// }
//
// invoked. This information can be retrieved with the StackTracer interface that returns a StackTrace.
Copy link
Member

Choose a reason for hiding this comment

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

It seems that all the comment in this file is aligned to 80 columns, should we also keep the format?

errors.go Outdated
// HasStack checks for this marker first.
// Annotate/Wrap and Annotatef/Wrapf will produce this marker.
type StackTraceAware interface {
hasStack() bool
Copy link
Member

Choose a reason for hiding this comment

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

should it be upper-case to HasStack?

group.go Outdated

// WalkDeep does a depth-first traversal of all errors.
// Any ErrorGroup is traversed (after going deep).
// The visitor function can return false to end the traversal early
Copy link
Member

Choose a reason for hiding this comment

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

from the code logic, in order to terminate the traversal the visitor must return true

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🤣 it's bug and never got to siblings, I try modify it and add a testcase. PTAL

group.go Outdated
}

// Go wide
if hasGroup, ok := err.(ErrorGroup); ok {
Copy link
Member

Choose a reason for hiding this comment

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

s/hasGroup/group/?

Copy link

@zhexuany zhexuany left a comment

Choose a reason for hiding this comment

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

LGTM

@zhexuany
Copy link

zhexuany commented Sep 6, 2018

Well, I don't have write access too.

group.go Outdated
func WalkDeep(err error, visitor func(err error) bool) bool {
// The visitor function can return true to end the traversal early
// In that case, WalkDeep will return true, otherwise false.
func WalkDeep(err error, visitor func(err error) bool) (done bool) {
Copy link

Choose a reason for hiding this comment

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

I tend to avoid named parameters since new gophers are not necessarily familiar with them and they create stateful variables. I like the concept of trying to give a name to return types, it would just be nice if they didn't come with the extra ability. If keeping this variable I would also name this "early" rather than "done": from the visitor function perspective it is "done", but from the perspective of calling "WalkDeep", it is always done when it returns.

Copy link
Collaborator Author

@lysu lysu Sep 6, 2018

Choose a reason for hiding this comment

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

agree~ I rename them.

ps: I am not often using named parameters, too..but preivous days, I read this golang/go#20859 issue make me changed 🤣

Copy link

Choose a reason for hiding this comment

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

Interesting

Copy link

Choose a reason for hiding this comment

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

Interesting

@gregwebs
Copy link

gregwebs commented Sep 6, 2018

I did already approve the PR, which in my understanding implies "LGTM".

Thanks for the follow up fixes!

@lysu
Copy link
Collaborator Author

lysu commented Sep 7, 2018

friendly ping @coocood

@coocood coocood merged commit f295249 into pingcap:master Sep 7, 2018
SwanSpouse pushed a commit to SwanSpouse/errors that referenced this pull request Jul 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants