mirror of https://github.com/grpc/grpc-go.git
Use codes.Code.String() rather than logging integers
This produces better human-readable error messages.
This commit is contained in:
parent
34384f34de
commit
9871e09f09
|
|
@ -377,7 +377,7 @@ type rpcError struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *rpcError) Error() string {
|
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.
|
// Code returns the error code for err if it was produced by the rpc system.
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ func TestHandlerTransport_NewServerHandlerTransport(t *testing.T) {
|
||||||
},
|
},
|
||||||
RequestURI: "/service/foo.bar",
|
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",
|
name: "with metadata",
|
||||||
|
|
|
||||||
|
|
@ -568,7 +568,7 @@ type StreamError struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e StreamError) Error() string {
|
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.
|
// ContextErr converts the error from context package into a StreamError.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue