← Back to Home

FMP Tools Documentation

Error Handling

Comprehensive guide to error handling in FMP Tools.

Overview

FMP Tools provide consistent error handling across all tools. When something goes wrong, you'll get clear, actionable error messages.

How Errors Work

All tools return a standardized response format:

Common Error Scenarios

API Key Issues

  • "API key not found" - Ensure FMP_API_KEY is set in your environment
  • "Invalid API key" - Check that your API key is correct and active

Data Issues

  • "Symbol not found" - The stock/ETF symbol doesn't exist or is invalid
  • "No data available" - The requested data isn't available for this symbol/date

Rate Limiting

  • "Rate limit exceeded" - You've hit the API rate limit
  • "Too many requests" - Slow down your requests

Network Issues

  • "Network error" - Connection problems
  • "Timeout" - Request took too long

Error Handling in Vercel AI SDK

Basic Error Handling

app/api/chat/route.ts

Advanced Error Handling

app/api/chat/route.ts

React Error Boundaries

Error Boundary Component

Using Error Boundaries

User-Facing Error Handling

Loading and Error States

Debugging Tips

Enable Debug Mode

app/api/chat/route.ts

Check Environment Variables

Best Practices

  1. Always implement error boundaries in React applications
  2. Log errors for debugging and monitoring
  3. Provide user-friendly error messages instead of technical details
  4. Handle loading states to improve user experience
  5. Implement retry logic for transient errors
  6. Monitor error rates in production

Next Steps