Error Handling
The LuxMart API uses standard HTTP status codes and returns error messages in JSON format.
HTTP Status Codes
| Code | Meaning | Description |
|---|---|---|
| 200 | OK | Request successful |
| 400 | Bad Request | Invalid request parameters or validation error |
| 401 | Unauthorized | Missing or invalid authentication token |
| 403 | Forbidden | Insufficient permissions for the requested resource |
| 404 | Not Found | Resource not found |
| 500 | Internal Server Error | Server error occurred |
Error Response Format
Errors are returned in the following format:
Or for validation errors:
Common Error Scenarios
Validation Errors
Request:
Response (400):
Authentication Errors
Request:
Response (401):
Not Found Errors
Request:
Response (404):
Permission Errors
Request:
Response (403):
Error Handling Best Practices
- Always check status codes before processing response data
- Handle 401 errors by prompting user to re-authenticate
- Handle 403 errors by showing appropriate permission messages
- Log 500 errors and report to support
- Validate input client-side to reduce 400 errors