return codes.OK for nil error

This commit is contained in:
iamqizhao
2015-04-15 11:41:42 -07:00
parent b8cfe25c6e
commit 6682b35fb6

View File

@ -208,6 +208,9 @@ func (e rpcError) Error() string {
// Code returns the error code for err if it was produced by the rpc system.
// Otherwise, it returns codes.Unknown.
func Code(err error) codes.Code {
if err == nil {
return codes.OK
}
if e, ok := err.(rpcError); ok {
return e.code
}