Comprehensive guide to handling API errors and status codes
Proper error handling is essential for building robust integrations with the G-Tateth API. This guide covers all error types, status codes, and best practices.
{ "success": false, "error": { "code": "VALIDATION_ERROR", "message": "Validation failed", "details": { "fields": { "email": ["Email is required", "Email format is invalid"], "phone": ["Phone number must be in E.164 format"] } } }}
Solution: Fix the validation errors and retry the request.
const errorMessages = { 'AUTH_REQUIRED': 'Please log in to continue', 'RATE_LIMIT_EXCEEDED': 'Too many requests. Please try again later.', 'VALIDATION_ERROR': 'Please check your input and try again.', 'RESOURCE_NOT_FOUND': 'The requested item could not be found.'};function getUserMessage(error) { return errorMessages[error.code] || error.message;}