mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-03 23:20:26 +08:00
优化错误提示
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
||||
"github.com/iwind/gosock/pkg/gosock"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/status"
|
||||
"gopkg.in/yaml.v3"
|
||||
"log"
|
||||
"net"
|
||||
@@ -832,7 +833,12 @@ func (this *APINode) unaryInterceptor(ctx context.Context, req any, info *grpc.U
|
||||
}
|
||||
result, err := handler(ctx, req)
|
||||
if err != nil {
|
||||
err = errors.New("'" + info.FullMethod + "()' says: " + err.Error())
|
||||
statusErr, ok := status.FromError(err)
|
||||
if ok {
|
||||
err = status.Error(statusErr.Code(), "'" + info.FullMethod + "()' says: " + err.Error())
|
||||
} else {
|
||||
err = errors.New("'" + info.FullMethod + "()' says: " + err.Error())
|
||||
}
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@ import (
|
||||
"github.com/iwind/TeaGo/dbs"
|
||||
"github.com/iwind/TeaGo/lists"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
type BaseService struct {
|
||||
@@ -229,7 +231,7 @@ func (this *BaseService) PermissionError() error {
|
||||
}
|
||||
|
||||
func (this *BaseService) NotImplementedYet() error {
|
||||
return errors.New("not implemented yet")
|
||||
return status.Error(codes.Unimplemented, "not implemented yet")
|
||||
}
|
||||
|
||||
// NullTx 空的数据库事务
|
||||
|
||||
Reference in New Issue
Block a user