Error Handling
Understanding how to handle errors properly is crucial for building robust applications with the Yuzu402 API.
Error Response Format
All errors follow a consistent JSON structure:
{
"success": false,
"error": {
"code": "ERROR_CODE",
"message": "Human-readable error description",
"details": {
"additionalInfo": "contextual information"
}
},
"timestamp": 1697234567890
}HTTP Status Codes
400
Bad Request
Invalid parameters, malformed JSON
401
Unauthorized
Missing or invalid API key
403
Forbidden
Insufficient permissions
404
Not Found
Resource doesn't exist
429
Too Many Requests
Rate limit exceeded
500
Internal Server Error
Server-side issue
503
Service Unavailable
Temporary service disruption
Common Error Codes
Authentication Errors
UNAUTHORIZED
Solution: Verify your API key is correct and included in the Authorization header.
FORBIDDEN
Solution: Upgrade your plan to access this endpoint.
Validation Errors
INVALID_PARAMETERS
Solution: Check the details object for specific parameter issues.
INVALID_PUBLIC_KEY
Solution: Ensure you're providing a valid base58-encoded Solana public key.
INVALID_MINT
Solution: Verify the token mint address is correct and the token exists.
Trading Errors
INSUFFICIENT_BALANCE
Solution: Ensure your wallet has enough SOL to cover the transaction amount plus fees.
SLIPPAGE_EXCEEDED
Solution: Increase slippage tolerance or retry the transaction when market is less volatile.
INSUFFICIENT_LIQUIDITY
Solution: Reduce trade size or wait for liquidity to improve.
Rate Limiting
RATE_LIMIT_EXCEEDED
Solution: Implement exponential backoff and respect the retryAfter value.
Network Errors
NETWORK_ERROR
Solution: Retry the request. If the issue persists, check the status page.
TRANSACTION_FAILED
Solution: Review the logs for specific failure reasons. May require parameter adjustments.
Implementing Error Handling
JavaScript/TypeScript Example
Python Example
Best Practices
Always Check Response Status: Don't assume requests succeeded
Handle Rate Limits Gracefully: Implement exponential backoff
Log Errors: Keep detailed logs for debugging
Retry Transient Errors: Network issues and rate limits are retryable
Don't Retry Non-Retryable Errors: Invalid parameters won't succeed on retry
Monitor Error Rates: High error rates may indicate issues with your integration
Use Timeouts: Don't let requests hang indefinitely
Getting Help
If you encounter persistent errors:
Check the Status Page for system issues
Review your code against the examples
Contact support with error details and request IDs
Follow us on Twitter for updates and community discussions
Last updated

