Files
descrybe/apps/api/internal/billing/client_errors.go
T
greeneclipse 8580c996c3 Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
2026-08-09 22:47:43 +02:00

37 lines
1.1 KiB
Go

package billing
import "errors"
var (
ErrPlanNameRequired = errors.New("name required")
ErrPlanNotFound = errors.New("plan not found")
ErrAmountRequired = errors.New("amount required")
ErrStripeNoCustomer = errors.New("no stripe customer for this company — complete a checkout first")
)
// ClientError reports whether err is a known client-facing billing/Stripe error.
func ClientError(err error) (msg string, ok bool) {
switch {
case err == nil:
return "", false
case errors.Is(err, ErrPlanNameRequired),
errors.Is(err, ErrPlanNotFound),
errors.Is(err, ErrAmountRequired),
errors.Is(err, ErrStripeNotConfigured),
errors.Is(err, ErrStripePlanUnsupported),
errors.Is(err, ErrStripePriceMissing),
errors.Is(err, ErrStripeNoCustomer),
errors.Is(err, ErrInsufficientCredits),
errors.Is(err, ErrProductLimitExceeded),
errors.Is(err, ErrAIRequiresUpgrade),
errors.Is(err, ErrEPRELRequiresUpgrade),
errors.Is(err, ErrUnknownFeatureKey),
errors.Is(err, ErrUnknownFeatureSection),
errors.Is(err, ErrInvalidFeatureGates),
errors.Is(err, ErrFeatureDisabled):
return err.Error(), true
default:
return "", false
}
}