errors

package
v0.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package errors defines domain errors for the subscription plugin.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Plan errors
	ErrPlanNotFound           = errors.New("plan not found")
	ErrPlanAlreadyExists      = errors.New("plan with this slug already exists")
	ErrPlanNotActive          = errors.New("plan is not active")
	ErrPlanHasSubscriptions   = errors.New("plan has active subscriptions and cannot be deleted")
	ErrInvalidPlanSlug        = errors.New("invalid plan slug")
	ErrInvalidBillingPattern  = errors.New("invalid billing pattern")
	ErrInvalidBillingInterval = errors.New("invalid billing interval")

	// Subscription errors
	ErrSubscriptionNotFound      = errors.New("subscription not found")
	ErrSubscriptionAlreadyExists = errors.New("organization already has an active subscription")
	ErrSubscriptionNotActive     = errors.New("subscription is not active")
	ErrSubscriptionCanceled      = errors.New("subscription is already canceled")
	ErrSubscriptionPaused        = errors.New("subscription is paused")
	ErrCannotDowngrade           = errors.New("cannot downgrade subscription with current usage")
	ErrInvalidQuantity           = errors.New("invalid subscription quantity")

	// Add-on errors
	ErrAddOnNotFound        = errors.New("add-on not found")
	ErrAddOnAlreadyExists   = errors.New("add-on with this slug already exists")
	ErrAddOnNotActive       = errors.New("add-on is not active")
	ErrAddOnNotAvailable    = errors.New("add-on is not available for this plan")
	ErrAddOnAlreadyAttached = errors.New("add-on is already attached to subscription")
	ErrAddOnNotAttached     = errors.New("add-on is not attached to subscription")
	ErrAddOnMaxQuantity     = errors.New("add-on maximum quantity exceeded")

	// Invoice errors
	ErrInvoiceNotFound    = errors.New("invoice not found")
	ErrInvoiceAlreadyPaid = errors.New("invoice is already paid")
	ErrInvoiceVoided      = errors.New("invoice has been voided")
	ErrInvoiceNotOpen     = errors.New("invoice is not open for payment")

	// Usage errors
	ErrUsageRecordNotFound  = errors.New("usage record not found")
	ErrDuplicateUsageRecord = errors.New("duplicate usage record (idempotency key)")
	ErrInvalidUsageMetric   = errors.New("invalid usage metric key")
	ErrInvalidUsageAction   = errors.New("invalid usage action")

	// Payment method errors
	ErrPaymentMethodNotFound      = errors.New("payment method not found")
	ErrPaymentMethodRequired      = errors.New("payment method is required")
	ErrPaymentMethodExpired       = errors.New("payment method is expired")
	ErrDefaultPaymentMethodDelete = errors.New("cannot delete default payment method")

	// Customer errors
	ErrCustomerNotFound      = errors.New("customer not found")
	ErrCustomerAlreadyExists = errors.New("customer already exists for organization")

	// Provider errors
	ErrProviderNotConfigured   = errors.New("payment provider is not configured")
	ErrProviderAPIError        = errors.New("payment provider API error")
	ErrWebhookSignatureInvalid = errors.New("invalid webhook signature")
	ErrWebhookEventUnhandled   = errors.New("webhook event not handled")

	// Feature/limit errors
	ErrFeatureLimitExceeded = errors.New("feature limit exceeded")
	ErrSeatLimitExceeded    = errors.New("seat limit exceeded")
	ErrSubscriptionRequired = errors.New("subscription is required")
	ErrTrialExpired         = errors.New("trial period has expired")
	ErrFeatureNotFound      = errors.New("feature not found")
	ErrFeatureAlreadyExists = errors.New("feature with this key already exists")
	ErrFeatureInUse         = errors.New("feature is linked to plans and cannot be deleted")
	ErrFeatureAlreadyLinked = errors.New("feature is already linked to this plan")
	ErrFeatureLinkNotFound  = errors.New("feature link not found")
	ErrFeatureNotAvailable  = errors.New("feature is not available for this subscription")
	ErrInvalidFeatureType   = errors.New("invalid feature type")
	ErrInvalidResetPeriod   = errors.New("invalid reset period")
	ErrInsufficientQuota    = errors.New("insufficient feature quota")
	ErrFeatureGrantNotFound = errors.New("feature grant not found")
	ErrFeatureUsageNotFound = errors.New("feature usage record not found")

	// General errors
	ErrInvalidCurrency = errors.New("invalid currency code")
	ErrInvalidAppID    = errors.New("invalid app ID")
	ErrInvalidOrgID    = errors.New("invalid organization ID")
	ErrUnauthorized    = errors.New("unauthorized access")
)

Domain errors for the subscription plugin

Functions

func IsConflictError

func IsConflictError(err error) bool

IsConflictError checks if the error is a conflict/duplicate error

func IsLimitError

func IsLimitError(err error) bool

IsLimitError checks if the error is a limit-related error

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError checks if the error is a "not found" type error

func IsPaymentError

func IsPaymentError(err error) bool

IsPaymentError checks if the error is payment-related

func IsValidationError

func IsValidationError(err error) bool

IsValidationError checks if the error is a validation error

Types

type SubscriptionError

type SubscriptionError struct {
	Err     error
	Message string
	Code    string
	Details map[string]interface{}
}

SubscriptionError represents a domain-specific error with additional context

func New

func New(err error, message string) *SubscriptionError

New creates a new subscription error with context

func (*SubscriptionError) Error

func (e *SubscriptionError) Error() string

Error implements the error interface

func (*SubscriptionError) Unwrap

func (e *SubscriptionError) Unwrap() error

Unwrap returns the underlying error

func (*SubscriptionError) WithCode

func (e *SubscriptionError) WithCode(code string) *SubscriptionError

WithCode adds an error code

func (*SubscriptionError) WithDetails

func (e *SubscriptionError) WithDetails(key string, value interface{}) *SubscriptionError

WithDetails adds details to the error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL