Commit 743b9278 by t0ng7u

🛠️ fix: billing session error handling for subscription-first fallback.

Aligns the error variable types in the subscription-first path so that quota fallback checks use the correct NewAPIError.
This prevents build failures and preserves the intended wallet fallback when subscription pre-consume returns an insufficient quota error.
parent 4fd8d033
...@@ -323,19 +323,19 @@ func NewBillingSession(c *gin.Context, relayInfo *relaycommon.RelayInfo, preCons ...@@ -323,19 +323,19 @@ func NewBillingSession(c *gin.Context, relayInfo *relaycommon.RelayInfo, preCons
case "subscription_first": case "subscription_first":
fallthrough fallthrough
default: default:
hasSub, err := model.HasActiveUserSubscription(relayInfo.UserId) hasSub, subCheckErr := model.HasActiveUserSubscription(relayInfo.UserId)
if err != nil { if subCheckErr != nil {
return nil, types.NewError(err, types.ErrorCodeQueryDataError, types.ErrOptionWithSkipRetry()) return nil, types.NewError(subCheckErr, types.ErrorCodeQueryDataError, types.ErrOptionWithSkipRetry())
} }
if !hasSub { if !hasSub {
return tryWallet() return tryWallet()
} }
session, err := trySubscription() session, apiErr := trySubscription()
if err != nil { if apiErr != nil {
if err.GetErrorCode() == types.ErrorCodeInsufficientUserQuota { if apiErr.GetErrorCode() == types.ErrorCodeInsufficientUserQuota {
return tryWallet() return tryWallet()
} }
return nil, err return nil, apiErr
} }
return session, nil return session, nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment