mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
grpc with detail return error
This commit is contained in:
parent
54bba9a867
commit
d50a24e9b1
@ -3,11 +3,12 @@ package mw
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/checker"
|
|
||||||
"math"
|
"math"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/checker"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||||
@ -31,7 +32,6 @@ func rpcString(v interface{}) string {
|
|||||||
|
|
||||||
func RpcServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
func RpcServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||||
log.ZDebug(ctx, "rpc server req", "req", rpcString(req))
|
log.ZDebug(ctx, "rpc server req", "req", rpcString(req))
|
||||||
|
|
||||||
//defer func() {
|
//defer func() {
|
||||||
// if r := recover(); r != nil {
|
// if r := recover(); r != nil {
|
||||||
// log.ZError(ctx, "rpc panic", nil, "FullMethod", info.FullMethod, "type:", fmt.Sprintf("%T", r), "panic:", r)
|
// log.ZError(ctx, "rpc panic", nil, "FullMethod", info.FullMethod, "type:", fmt.Sprintf("%T", r), "panic:", r)
|
||||||
@ -145,7 +145,8 @@ func RpcServerInterceptor(ctx context.Context, req interface{}, info *grpc.Unary
|
|||||||
}
|
}
|
||||||
details, err := grpcStatus.WithDetails(errInfo)
|
details, err := grpcStatus.WithDetails(errInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.ZWarn(ctx, "rpc server resp", err, "funcName", funcName)
|
||||||
|
return nil, errs.Wrap(err)
|
||||||
}
|
}
|
||||||
log.ZWarn(ctx, "rpc server resp", err, "funcName", funcName)
|
log.ZWarn(ctx, "rpc server resp", err, "funcName", funcName)
|
||||||
return nil, details.Err()
|
return nil, details.Err()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user