Error Codes
Comprehensive guide to FinFusion API error codes and handling
Error Response Format
Overview
The FinFusion API uses conventional HTTP response codes to indicate the success or failure of an API request. Codes in the 2xx range indicate success, codes in the 4xx range indicate an error with the provided information, and codes in the 5xx range indicate an error with our servers.
Error Types
AuthenticationError
401Issues with API keys or authentication tokens
ValidationError
400Invalid request parameters or payload
RateLimitError
429Too many requests within a time window
APIError
500Internal server errors or API issues
Error Codes
Authentication Errors
Code | Message | Description |
---|---|---|
AUTH001 | Invalid API key | The provided API key is invalid or has been revoked |
AUTH002 | Expired token | The authentication token has expired |
AUTH003 | Invalid scope | The API key does not have permission for this operation |
Validation Errors
Code | Message | Description |
---|---|---|
VAL001 | Invalid request payload | The request body contains invalid or missing fields |
VAL002 | Invalid parameter | One or more query parameters are invalid |
VAL003 | Resource not found | The requested resource does not exist |
Rate Limit Errors
Code | Message | Description |
---|---|---|
RATE001 | Rate limit exceeded | You have exceeded the allowed number of requests |
RATE002 | Concurrent request limit | Too many concurrent requests |
API Errors
Code | Message | Description |
---|---|---|
API001 | Internal server error | An unexpected error occurred on our servers |
API002 | Service unavailable | The requested service is temporarily unavailable |
Handling Errors
Here's an example of how to handle different types of errors in your code:
try {
const payment = await finfusion.payments.create({
amount: -100, // Invalid amount
currency: 'USD'
});
} catch (error) {
if (error instanceof ValidationError) {
console.error('Validation Error:', error.message);
console.error('Error Code:', error.code);
console.error('Details:', error.details);
} else if (error instanceof AuthenticationError) {
console.error('Authentication Error:', error.message);
} else {
console.error('Unexpected Error:', error);
}
}
Best Practices
- • Always check for specific error types before handling general errors
- • Log error details for debugging
- • Implement proper retry logic for rate limit errors
- • Handle authentication errors by refreshing tokens when appropriate
- • Provide meaningful error messages to end users