ing
This commit is contained in:
parent
15614dd52a
commit
9c024a9f88
|
@ -72,12 +72,18 @@ func (s *RPCServlets) Handle(servletCtx server.ServletCtx,
|
||||||
params, err = src.Params()
|
params, err = src.Params()
|
||||||
if nil != err {
|
if nil != err {
|
||||||
logging.Logger().Errore(err)
|
logging.Logger().Errore(err)
|
||||||
|
s.writeError(crp.E_BAD_PARAMS, "", err)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
grpcCtx = context.Background()
|
grpcCtx = context.Background()
|
||||||
grpcReply, err = ogeg.Exec(grpcCTX, m, p...)
|
grpcReply, err = ogeg.Exec(grpcCtx, method, params...)
|
||||||
replyBuff, err = src.NewResponseWithString(grpcReply, err)
|
replyBuff, err = src.NewResponseWithString(grpcReply, err)
|
||||||
|
if nil != err {
|
||||||
|
logging.Logger().Errore(err)
|
||||||
|
s.writeError(crp.E_INTERNAL, "", err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
writeChan <- replyBuff
|
writeChan <- replyBuff
|
||||||
case <-stopChan:
|
case <-stopChan:
|
||||||
|
@ -87,3 +93,22 @@ func (s *RPCServlets) Handle(servletCtx server.ServletCtx,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *RPCServlets) writeError(src crp.ServerRequestCodec, writeChan chan<- []byte, code int, message string, data interface{}) {
|
||||||
|
if !src.HasResponse() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
pErr := &crp.Error{
|
||||||
|
Code: code,
|
||||||
|
Message: message,
|
||||||
|
Data: data,
|
||||||
|
}
|
||||||
|
|
||||||
|
buf, err := src.NewResponse(nil, pErr)
|
||||||
|
if nil != err {
|
||||||
|
logging.Logger().Errore(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
writeChan <- buf
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user