Module: Spree::Api::V3::ErrorHandler

Extended by:
ActiveSupport::Concern
Included in:
BaseController, JwtAuthentication
Defined in:
app/controllers/concerns/spree/api/v3/error_handler.rb

Constant Summary collapse

ERROR_CODES =

Stripe-style error codes for consistent API error responses

{
  # Authentication & authorization errors
  authentication_required: 'authentication_required',
  authentication_failed: 'authentication_failed',
  access_denied: 'access_denied',
  invalid_token: 'invalid_token',
  invalid_provider: 'invalid_provider',
  invalid_refresh_token: 'invalid_refresh_token',
  current_password_invalid: 'current_password_invalid',
  password_reset_token_invalid: 'password_reset_token_invalid',
  redirect_url_not_allowed: 'redirect_url_not_allowed',

  # Resource errors
  record_not_found: 'record_not_found',
  resource_invalid: 'resource_invalid',

  # Cart errors
  cart_not_found: 'cart_not_found',
  cart_cannot_transition: 'cart_cannot_transition',
  cart_empty: 'cart_empty',
  cart_invalid_state: 'cart_invalid_state',
  cart_already_updated: 'cart_already_updated',
  cart_cannot_complete: 'cart_cannot_complete',

  # Order errors
  order_not_found: 'order_not_found',

  # Line item errors
  line_item_not_found: 'line_item_not_found',
  variant_not_found: 'variant_not_found',
  insufficient_stock: 'insufficient_stock',
  invalid_quantity: 'invalid_quantity',

  # Validation errors
  validation_error: 'validation_error',
  parameter_missing: 'parameter_missing',
  parameter_invalid: 'parameter_invalid',

  # Payment errors
  payment_failed: 'payment_failed',
  payment_processing_error: 'payment_processing_error',
  gateway_error: 'gateway_error',

  # Gift card errors
  gift_card_not_found: 'gift_card_not_found',
  gift_card_expired: 'gift_card_expired',
  gift_card_already_redeemed: 'gift_card_already_redeemed',

  # Digital download errors
  attachment_missing: 'attachment_missing',
  download_unauthorized: 'download_unauthorized',
  digital_link_expired: 'digital_link_expired',
  download_limit_exceeded: 'download_limit_exceeded',

  # Rate limiting errors
  rate_limit_exceeded: 'rate_limit_exceeded',

  # Idempotency errors
  idempotency_key_reused: 'idempotency_key_reused',

  # Request errors
  request_too_large: 'request_too_large',

  # General errors
  processing_error: 'processing_error',
  invalid_request: 'invalid_request'
}.freeze