Skip to main content

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

4xx Client Errors

400 - Bad Request
401 - Unauthorized
403 - Forbidden
404 - Not Found
409 - Conflict

5xx Server Errors

500 - Internal Server Error
502 - Bad Gateway
503 - Service Unavailable

Payment Errors

402 - Payment Required
422 - Payment Failed
424 - Payment Processing

Common Error Types

Authentication Errors

When: User is not authenticated
Solution: Redirect to login page or show authentication prompt
When: User lacks required permissions
Solution: Show access denied message or upgrade account prompt

Validation Errors

When: Request data is invalid
Solution: Show field-specific error messages to user
When: Resource already exists or conflicts
Solution: Redirect to existing resource or offer update option

Business Logic Errors

When: Not enough inventory for order
Solution: Update cart quantities or remove unavailable items
When: Store is not accepting orders
Solution: Show store status and suggest alternatives

Payment Errors

When: Payment method declined
Solution: Ask user to try different payment method
When: Payment processing error
Solution: 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.
Always handle errors gracefully in your UI and provide clear feedback to users about what went wrong and how to resolve it.