add warning when handler returns not *errors.Error or proto.Message error type

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-10-08 13:42:27 +03:00
parent a41e085d18
commit 0d3d13b7ab

View File

@ -476,6 +476,9 @@ func (g *grpcServer) processRequest(stream grpc.ServerStream, service *service,
return err return err
} }
default: default:
if logger.V(logger.ErrorLevel) {
logger.Warn("handler error will not be transferred properly, must return *errors.Error or proto.Message")
}
// default case user pass own error type that not proto based // default case user pass own error type that not proto based
statusCode = convertCode(verr) statusCode = convertCode(verr)
statusDesc = verr.Error() statusDesc = verr.Error()
@ -595,6 +598,9 @@ func (g *grpcServer) processStream(stream grpc.ServerStream, service *service, m
return err return err
} }
default: default:
if logger.V(logger.ErrorLevel) {
logger.Warn("handler error will not be transferred properly, must return *errors.Error or proto.Message")
}
// default case user pass own error type that not proto based // default case user pass own error type that not proto based
statusCode = convertCode(verr) statusCode = convertCode(verr)
statusDesc = verr.Error() statusDesc = verr.Error()