Skip to content

Commit

Permalink
Merge pull request #177 from icey-yu/fix-rpc
Browse files Browse the repository at this point in the history
fix: rpc recover
  • Loading branch information
icey-yu authored Dec 12, 2024
2 parents fe2a5ec + 9ce75d4 commit 999cc77
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions mw/rpc_server_interceptor.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
// Copyright © 2023 OpenIM. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package mw

import (
Expand Down Expand Up @@ -47,6 +33,11 @@ func RpcServerInterceptor(ctx context.Context, req any, info *grpc.UnaryServerIn
return nil, err
}

defer func() {
if r := recover(); r != nil {
log.ZPanic(ctx, "RpcServerInterceptor panic", r)
}
}()
resp, err := handler(ctx, req)
if err != nil {
return nil, handleError(ctx, funcName, req, err)
Expand Down

0 comments on commit 999cc77

Please sign in to comment.