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

multi: define wire error types. #2055

Merged
merged 1 commit into from
Feb 14, 2020
Merged

Conversation

dnldd
Copy link
Member

@dnldd dnldd commented Jan 30, 2020

This updates the wire error type by clearly defining package errors and updating call sites.

This is work towards #350.

@dnldd dnldd marked this pull request as ready for review January 31, 2020 19:25
Copy link
Member

@matheusd matheusd left a comment

Choose a reason for hiding this comment

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

Just a couple of suggestions for the design of ErrorCode and MessageError. I'm not sure whether these were already considered or not so I'm just recording them here.

Feel free to ignore them if this has already been discussed and the design of the error structures explicitly decided as they were implemented.

wire/error.go Show resolved Hide resolved
wire/error.go Outdated Show resolved Hide resolved
wire/error.go Outdated Show resolved Hide resolved
@jrick
Copy link
Member

jrick commented Feb 6, 2020

How are these error codes going to be used to solve the linked issue? I'm not sure what the plan is with them or why they are necessary.

@dnldd
Copy link
Member Author

dnldd commented Feb 6, 2020

Errors generated processing messages from peers can now be checked if they're bannable or not with these definitions. Take a look at IsBannable.

Copy link
Member

@davecgh davecgh left a comment

Choose a reason for hiding this comment

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

So, now that the intent is to create more programmatically identifiable errors, I would highly recommend that the textual prefix of the function in the error messages be removed in favor a new field in the Error struct which identifies the originating message. That way it's not only possible to switch on the specific error code, but the origin message type could also be examined. I can foresee that being an important distinction as something more generic like ErrInvalidMsg might have different behavior depending on the specific type of message.

It will also significantly clean up the error messages and reduce the need to repeat the function name constantly, which is error prone and I would be willing to bet there are cases where it's not even correct anyway.

wire/error.go Outdated Show resolved Hide resolved
wire/error.go Show resolved Hide resolved
wire/error.go Outdated Show resolved Hide resolved
@dnldd
Copy link
Member Author

dnldd commented Feb 13, 2020

I agree, adding the originating message to the error as you stated should clean up the error message, reduce the function name repetition and also provide more context. I'm going to get that done in a different PR.

wire/msgversion.go Outdated Show resolved Hide resolved
wire/message_test.go Outdated Show resolved Hide resolved
wire/message_test.go Outdated Show resolved Hide resolved
wire/common.go Outdated Show resolved Hide resolved
wire/msgaddr.go Outdated Show resolved Hide resolved
wire/error.go Outdated Show resolved Hide resolved
wire/error.go Outdated Show resolved Hide resolved
wire/error.go Outdated Show resolved Hide resolved
wire/error.go Outdated Show resolved Hide resolved
wire/error_test.go Outdated Show resolved Hide resolved
@davecgh davecgh added this to the 1.6.0 milestone Feb 14, 2020
wire/error.go Outdated Show resolved Hide resolved
wire/msgaddr.go Outdated Show resolved Hide resolved
wire/msggetdata.go Outdated Show resolved Hide resolved
This updates the wire error type by clearly
defining package errors and updating call sites.
@davecgh davecgh merged commit 6a351fa into decred:master Feb 14, 2020
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.

None yet

4 participants