Skip to content

Commit 999cc77

Browse files
authored
Merge pull request #177 from icey-yu/fix-rpc
fix: rpc recover
2 parents fe2a5ec + 9ce75d4 commit 999cc77

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

mw/rpc_server_interceptor.go

+5-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
// Copyright © 2023 OpenIM. All rights reserved.
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
14-
151
package mw
162

173
import (
@@ -47,6 +33,11 @@ func RpcServerInterceptor(ctx context.Context, req any, info *grpc.UnaryServerIn
4733
return nil, err
4834
}
4935

36+
defer func() {
37+
if r := recover(); r != nil {
38+
log.ZPanic(ctx, "RpcServerInterceptor panic", r)
39+
}
40+
}()
5041
resp, err := handler(ctx, req)
5142
if err != nil {
5243
return nil, handleError(ctx, funcName, req, err)

0 commit comments

Comments
 (0)