mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-24 06:34:42 +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())
|
var NilError = reflect.Zero(reflect.TypeOf((*error)(nil)).Elem())
|
||||||
|
|
||||||
type RpcError string
|
type RpcError string
|
||||||
|
var noError RpcError
|
||||||
func (e RpcError) Error() string {
|
func (e RpcError) Error() string {
|
||||||
return string(e)
|
return string(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConvertError(e error) RpcError{
|
func ConvertError(e error) RpcError{
|
||||||
if e == nil {
|
if e == nil {
|
||||||
return ""
|
return noError
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcErr := RpcError(e.Error())
|
rpcErr := RpcError(e.Error())
|
||||||
|
|||||||
@@ -316,9 +316,11 @@ func (server *Server) selfNodeRpcHandlerAsyncGo(client *Client,callerRpcHandler
|
|||||||
ReleaseRpcRequest(req)
|
ReleaseRpcRequest(req)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if len(Err) == 0 {
|
||||||
pCall.Err = Err
|
pCall.Err = nil
|
||||||
|
}else{
|
||||||
|
pCall.Err = Err
|
||||||
|
}
|
||||||
|
|
||||||
if Returns!=nil {
|
if Returns!=nil {
|
||||||
pCall.Reply = Returns
|
pCall.Reply = Returns
|
||||||
|
|||||||
Reference in New Issue
Block a user