Overview
The Twigz API provides comprehensive error handling with structured error responses, proper HTTP status codes, and detailed error information to help developers build robust applications.Error Response Format
All API errors follow a consistent structure:HTTP Status Codes
2xx Success
200 - OK
201 - Created
204 - No Content
201 - Created
204 - No Content
4xx Client Errors
400 - Bad Request
401 - Unauthorized
403 - Forbidden
404 - Not Found
409 - Conflict
401 - Unauthorized
403 - Forbidden
404 - Not Found
409 - Conflict
5xx Server Errors
500 - Internal Server Error
502 - Bad Gateway
503 - Service Unavailable
502 - Bad Gateway
503 - Service Unavailable
Payment Errors
402 - Payment Required
422 - Payment Failed
424 - Payment Processing
422 - Payment Failed
424 - Payment Processing
Common Error Types
Authentication Errors
401 - Authentication Required
401 - Authentication Required
When: User is not authenticatedSolution: Redirect to login page or show authentication prompt
403 - Insufficient Permissions
403 - Insufficient Permissions
When: User lacks required permissionsSolution: Show access denied message or upgrade account prompt
Validation Errors
400 - Validation Failed
400 - Validation Failed
When: Request data is invalidSolution: Show field-specific error messages to user
409 - Resource Conflict
409 - Resource Conflict
When: Resource already exists or conflictsSolution: Redirect to existing resource or offer update option
Business Logic Errors
400 - Insufficient Stock
400 - Insufficient Stock
When: Not enough inventory for orderSolution: Update cart quantities or remove unavailable items
400 - Store Inactive
400 - Store Inactive
When: Store is not accepting ordersSolution: Show store status and suggest alternatives
Payment Errors
402 - Payment Declined
402 - Payment Declined
When: Payment method declinedSolution: Ask user to try different payment method
422 - Payment Processing Failed
422 - Payment Processing Failed
When: Payment processing errorSolution: Allow retry or suggest alternative payment method
Error Handling Patterns
React Error Boundary
Retry Mechanisms
The API uses Convex’s built-in error handling which provides structured errors with proper typing and automatic retry mechanisms for transient failures.
