Error Handling Reference
Comprehensive error handling guide for the Market Sentiment Analyzer.
API Errors
Fear & Greed Index Unavailable
Error: Cannot fetch Fear & Greed Index from Alternative.me API
Symptoms:
Fear & Greed Index unavailable
Using cached/fallback value
Causes:
- API rate limiting (>10 requests/minute)
- API server downtime
- Network connectivity issues
Solutions:
- Automatic: Uses cached value with "stale" warning
- Manual: Wait 1-2 minutes and retry
- Persistent: Check https://alternative.me/crypto/fear-and-greed-index/ status
Impact: Composite score uses cached or neutral (50) value
CoinGecko API Rate Limit
Error: Market momentum data unavailable
Symptoms:
API request failed: 429 Too Many Requests
Market data unavailable
Causes:
- Exceeded free tier limit (~10-30 calls/minute)
- Too many concurrent requests
Solutions:
- Automatic: Falls back to cached data
- Manual: Wait 60 seconds before retry
- Upgrade: CoinGecko Pro API for higher limits
Impact: Momentum component uses neutral (50) value
News Feed Unavailable
Error: Cannot fetch news from RSS feeds
Symptoms:
Failed to fetch [feed_url]: Connection timed out
No articles available
Causes:
- RSS feed URL changed
- Feed server downtime
- Network firewall blocking
Solutions:
- Automatic: Skips unavailable feeds, uses others
- Check: Verify feed URLs in settings
- Network: Test connectivity to feed domains
Impact: News sentiment based on fewer articles; score may be less representative
Data Parsing Errors
Invalid JSON Response
Error: Failed to parse API response
Symptoms:
json.JSONDecodeError: Expecting value
Failed to parse response: [error details]
Causes:
- API returning HTML error page instead of JSON
- Malformed API response
- Incomplete response due to timeout
Solutions:
- Check API status pages
- Verify API endpoint URLs
- Increase timeout in settings
Missing Data Fields
Error: Expected field not in response
Symptoms:
KeyError: 'price_change_percentage_24h'
Causes:
- API schema changed
- New coin not fully supported
- Delisted coin
Solutions:
- Update to latest script version
- Use market-wide analysis instead of coin-specific
- Report issue if persistent
Configuration Errors
Invalid Weights
Error: Custom weights don't sum to 1.0
Note: This is auto-corrected, not a fatal error
Causes:
- User-provided weights like "news:0.5,fng:0.5,momentum:0.5" (sum > 1)
Solutions:
- Automatic: Weights are normalized
- Manual: Ensure weights sum to 1.0
Unknown Coin Symbol
Error: Coin not found in known mappings
Symptoms:
No data for [COIN], using market analysis
Causes:
- Coin symbol not in known mappings
- New coin not yet added
- Typo in symbol
Solutions:
- Use common symbols (BTC, ETH, SOL, etc.)
- Try full CoinGecko ID instead of symbol
- Fall back to market-wide analysis
Graceful Degradation
The analyzer implements graceful degradation:
Full Analysis (all 3 components)
│
├─► Fear & Greed fails → Use cached/neutral (50)
│
├─► News fails → Use remaining components with adjusted weights
│
├─► Momentum fails → Use remaining components with adjusted weights
│
└─► All fail → Return neutral (50) with error warnings
Component Failure Handling
| Component | Fallback | Score Used |
|---|---|---|
| Fear & Greed | Cached → Neutral | Cached value or 50 |
| News Sentiment | Skip | 50 (neutral) |
| Market Momentum | Cached → Neutral | Cached value or 50 |
Diagnostic Commands
Test Individual Components
# Test Fear & Greed
python fear_greed.py -v
# Test News Sentiment
python news_sentiment.py -v
# Test Market Momentum
python market_momentum.py -v
# Full analysis with verbose
python sentiment_analyzer.py -v
Check Cache Files
# List cache files
ls -la scripts/.*.json
# View cached data
cat scripts/.fng_cache.json | python -m json.tool
Clear Caches
rm scripts/.fng_cache.json
rm scripts/.news_cache.json
rm scripts/.momentum_cache.json
Common Issues
Issue: Score Always Neutral (50)
Causes:
- All APIs unavailable
- Network connectivity issues
- VPN blocking API access
Diagnosis:
# Run with verbose
python sentiment_analyzer.py -v
# Check network
curl -I https://api.alternative.me/fng/
curl -I https://api.coingecko.com/api/v3/ping
Issue: News Sentiment Skewed
Causes:
- Only one RSS feed responding
- Feed returns old articles
- Keyword bias in recent news
Diagnosis:
python news_sentiment.py -v
# Check "articles_analyzed" count
# Should be 15-50 for balanced sentiment
Issue: Slow Response Time
Causes:
- Cache expired, fetching fresh data
- Network latency to APIs
- API rate limiting delays
Solutions:
- Increase cache TTL in settings
- Use
--verboseto see timing - Consider local caching proxy