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
Improve error msg by using the error pkg #4461
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The errors package is no longer maintained and we should stop using it. Since a couple of releases, Go has the verb %w
that can be used when supplying an error to produce a meaningful message that includes Unwrap
information.
While I agree with @ale-linux in theory since Go added better error wrapping support in The Fabric doc also advises developers to use Maybe we should open a future issue to convert |
common/cauthdsl/policy.go
Outdated
@@ -32,11 +30,11 @@ func NewPolicyProvider(deserializer msp.IdentityDeserializer) policies.Provider | |||
func (pr *provider) NewPolicy(data []byte) (policies.Policy, proto.Message, error) { | |||
sigPolicy := &cb.SignaturePolicyEnvelope{} | |||
if err := proto.Unmarshal(data, sigPolicy); err != nil { | |||
return nil, nil, fmt.Errorf("Error unmarshalling to SignaturePolicy: %s", err) | |||
return nil, nil, errors.Errorf("error unmarshalling to SignaturePolicy: %s", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do stick with github.com/pkg/errors
for now, I think this one should use errors.Wrap() rather than errors.Errorf() as described at https://hyperledger-fabric.readthedocs.io/en/latest/error-handling.html.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, let me update and clean up other places.
The patchset improves the error message. The errors package has better features than the fmt package in terms of error processing. E.g., errors.Errorf records the stack trace at the point it is called. On the other hand, the patchset eliminates the usage of fmt package. Change-Id: I7d7bb084d0ba9d6d33a2b583a763752fca530b9b Signed-off-by: Baohua Yang <yangbaohua@gmail.com> Signed-off-by: Baohua Yang <baohua.yang@oracle.com>
This will need lots of efforts. Do we need to wait till the |
The My suggestion would be to not make these error handling changes until we've got some more opinions gathered in #4468. |
The patchset improves the error message.
Change-Id: I7d7bb084d0ba9d6d33a2b583a763752fca530b9b
Type of change
Description
The errors package has better features than the fmt package in terms of error processing. E.g., errors.Errorf records the stack trace at the point it is called.
On the other hand, the patchset eliminates the usage of fmt package.
Additional details
N/A
Related issues
N/A
Release Note
N/A