Changed encoding/decoding error code from InvalidArgument to Internal #2251
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Functions newClientEncodingError and newServerEncodingError are called only when encoding/decoding attempt is failed, which means that either structure can't be transformed into bytes, or bytes can't be read into structure.
Currently such errors lead to CodeInvalidArgument (3) return code.
As yarpc error codes relates to grpc error codes, we may assume that meaning is also close (if not the same). In grpc-go source code the same encoding/decoding errors lead to CodeInternal code (1, 2), and so the same code should be returned in yarpc.
This PR changes CodeInvalidArgument (3) to CodeInternal(13) for most such cases.
Except for server decoding errors. If server can't decode body or header of the request, it indeed indicates that client tries to send something unexpected. (This is a change from previous review.)
It's an API change, but in a worst case we expect to have more visibility on problems that were hidden by "client errors".