mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-03 22:45:13 +08:00
优化error空值返回
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user