修复错误的状态码
This commit is contained in:
@@ -5,6 +5,7 @@ package asset
|
||||
|
||||
import (
|
||||
"context"
|
||||
stderrors "errors"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
@@ -520,7 +521,12 @@ func (s *Service) GetCurrentPackage(ctx context.Context, assetType string, id ui
|
||||
|
||||
usage, err := s.packageUsageStore.GetActiveMainPackage(ctx, carrierType, id)
|
||||
if err != nil {
|
||||
return nil, errors.New(errors.CodeNotFound, "当前无生效套餐")
|
||||
// 记录不存在表示当前无生效套餐,属于正常业务状态,返回 nil 而非错误
|
||||
// 其他 DB 错误才作为服务端错误处理
|
||||
if stderrors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, errors.Wrap(errors.CodeDatabaseError, err, "查询当前生效套餐失败")
|
||||
}
|
||||
|
||||
pkg, pkgErr := s.packageStore.GetByID(ctx, usage.PackageID)
|
||||
|
||||
Reference in New Issue
Block a user