code in "github.com/micro/[email protected]/server/grpc/grpc.go:340"
fn := func(ctx context.Context, req server.Request, rsp interface{}) error {
defer func() {
if r := recover(); r != nil {
log.Logf("handler %s panic recovered, err: %s", mtype.method.Name, r)
}
}()
.....
return nil
}
I think should return error.
Thanks for answering my question.
How would we do that?
Let development handle returns errors.Otherwise, it's hard to tell the difference between no data and errors.
like
fn := func(ctx context.Context, req server.Request, rsp interface{}) (e error) {
defer func() {
if r := recover(); r != nil {
log.Logf("handler %s panic recovered, err: %s", mtype.method.Name, r)
e = errors.InternalServerError("go.micro.server", "panic recovered: %v", r)
}
}()
....
return
}
Feel free to submit a PR
I think the motivation to recover from the panic is fine (maybe a good idea). Something similar is implemented here: https://github.com/micro/go-micro/blob/master/server/rpc_server.go#L90
I have submitted a PR to improve this: https://github.com/micro/go-micro/pull/906
I saw the PR has been merged and released. Can we close this issue?
Thanks for your help
@aimpsmile can you close this issue?
hi all , i am still confused why just recover() after panic, but not return error?
could you explain more, plz?
yes, i think that we need fix that