Use codes.Code.String() rather than logging integers

This produces better human-readable error messages.
This commit is contained in:
Tamir Duberstein 2016-12-19 15:48:27 -05:00
parent 34384f34de
commit 9871e09f09
No known key found for this signature in database
GPG Key ID: 1C1E98CC8E17BB89
3 changed files with 3 additions and 3 deletions

View File

@ -377,7 +377,7 @@ type rpcError struct {
}
func (e *rpcError) Error() string {
return fmt.Sprintf("rpc error: code = %d desc = %s", e.code, e.desc)
return fmt.Sprintf("rpc error: code = %s desc = %s", e.code, e.desc)
}
// Code returns the error code for err if it was produced by the rpc system.

View File

@ -188,7 +188,7 @@ func TestHandlerTransport_NewServerHandlerTransport(t *testing.T) {
},
RequestURI: "/service/foo.bar",
},
wantErr: `stream error: code = 13 desc = "malformed time-out: transport: timeout unit is not recognized: \"tomorrow\""`,
wantErr: `stream error: code = Internal desc = "malformed time-out: transport: timeout unit is not recognized: \"tomorrow\""`,
},
{
name: "with metadata",

View File

@ -568,7 +568,7 @@ type StreamError struct {
}
func (e StreamError) Error() string {
return fmt.Sprintf("stream error: code = %d desc = %q", e.Code, e.Desc)
return fmt.Sprintf("stream error: code = %s desc = %q", e.Code, e.Desc)
}
// ContextErr converts the error from context package into a StreamError.