优化error空值返回

This commit is contained in:
boyce
2020-11-12 17:10:40 +08:00
parent 200f2d2fee
commit 0d07da1a2b
2 changed files with 7 additions and 5 deletions

View File

@@ -16,14 +16,14 @@ type FuncRpcServer func() (*Server)
var NilError = reflect.Zero(reflect.TypeOf((*error)(nil)).Elem())
type RpcError string
var noError RpcError
func (e RpcError) Error() string {
return string(e)
}
func ConvertError(e error) RpcError{
if e == nil {
return ""
return noError
}
rpcErr := RpcError(e.Error())

View File

@@ -316,9 +316,11 @@ func (server *Server) selfNodeRpcHandlerAsyncGo(client *Client,callerRpcHandler
ReleaseRpcRequest(req)
return
}
pCall.Err = Err
if len(Err) == 0 {
pCall.Err = nil
}else{
pCall.Err = Err
}
if Returns!=nil {
pCall.Reply = Returns