Error Handling Reference
Comprehensive guide to errors, causes, and solutions for the tracking-crypto-prices skill.
Error Categories
1. API Errors
RateLimitError
Message: Rate limit exceeded. Retry after Xs
Cause: CoinGecko API rate limit reached (10-50 calls/minute for free tier).
Solution:
- Wait for the indicated retry period
- Enable caching to reduce API calls
- Consider getting a CoinGecko API key for higher limits
Prevention:
# In config/settings.yaml
cache:
enabled: true
spot_ttl: 30 # Cache spot prices for 30 seconds
NetworkError
Message: Connection failed: [details] or Request timed out
Cause: No internet connection or CoinGecko API unreachable.
Solution:
- Check internet connection
- Cached data will be used automatically if available
- yfinance fallback will be attempted if configured
Fallback Behavior:
Primary: CoinGecko API
↓ (fails)
Fallback: yfinance (if installed)
↓ (fails)
Last Resort: Stale cache (if --allow-stale)
SymbolNotFoundError
Message: Unknown symbol: XYZ
Cause: The cryptocurrency ticker or CoinGecko ID doesn't exist.
Solution:
- Check spelling (symbols are case-insensitive)
- Use
--listto search for valid symbols:python price_tracker.py --list --query bitcoin - Use CoinGecko ID instead of ticker (e.g.,
avalanche-2notAVAX)
Common Mapping Issues:
| Ticker | CoinGecko ID | Notes |
|---|---|---|
| AVAX | avalanche-2 | Not "avalanche" |
| MATIC | matic-network | Polygon network |
| COMP | compound-governance-token | Full name |
| CRV | curve-dao-token | Full name |
2. Cache Errors
Cache Stale Warning
Message: Warning: Using stale cache for XYZ
Cause: Fresh data unavailable, returning expired cache entry.
Solution:
- Not a critical error; stale data is returned with
_stale: trueflag - Use
--no-cacheto force fresh fetch - Clear cache with
--clear-cacheif data seems corrupted
Cache Write Failed
Message: Silent failure (logged in verbose mode)
Cause: Cannot write to cache directory (permissions or disk space).
Solution:
- Check cache directory permissions:
ls -la ./data/ - Ensure disk space available
- Configure alternate cache directory in settings.yaml
3. Configuration Errors
Missing Dependencies
Message: ImportError: No module named 'requests'
Cause: Required Python packages not installed.
Solution:
pip install requests pandas yfinance
Optional packages:
pip install pyyaml python-dotenv
Invalid Configuration
Message: Various YAML parsing errors
Cause: Malformed settings.yaml file.
Solution:
- Validate YAML syntax
- Check indentation (use spaces, not tabs)
- Delete settings.yaml to use defaults
Validation:
python -c "import yaml; yaml.safe_load(open('config/settings.yaml'))"
Unknown Watchlist
Message: Error: Unknown watchlist 'xyz'
Cause: Requested watchlist not defined in configuration.
Solution:
- Use a predefined watchlist:
top10,defi,layer2,stablecoins,memecoins - Define custom watchlist in settings.yaml:
watchlists: custom: - bitcoin - ethereum - solana
4. Output Errors
File Write Error
Message: Error writing to output file
Cause: Cannot write to specified output path.
Solution:
- Check directory exists
- Check file permissions
- Ensure path is valid
Error Handling Strategy
Automatic Fallback Chain
1. CoinGecko API (primary)
↓ RateLimitError or NetworkError
2. yfinance (fallback)
↓ ImportError or APIError
3. Stale Cache (last resort)
↓ No cache available
4. Error reported to user
Graceful Degradation
| Scenario | Behavior |
|---|---|
| Rate limited | Auto-retry with exponential backoff |
| Network error | Use fallback source or cache |
| Partial failure | Return successful results with warnings |
| Total failure | Clear error message with suggestions |
Retry Logic
# Built-in retry with exponential backoff
Attempt 1: Immediate
Attempt 2: Wait 2 seconds
Attempt 3: Wait 4 seconds
(Give up and try fallback)
Debugging
Enable Verbose Output
python price_tracker.py --symbol BTC --verbose
Shows:
- API calls being made
- Cache hits/misses
- Fallback attempts
- Timing information
Check Cache Status
# In Python
from cache_manager import CacheManager
cache = CacheManager()
print(cache.get_stats())
Force Fresh Data
# Bypass cache entirely
python price_tracker.py --symbol BTC --no-cache
# Clear all cached data
python price_tracker.py --clear-cache
Error Codes
| Code | Category | Meaning |
|---|---|---|
| 1 | General | Command-line argument error |
| 2 | Network | API connection failed |
| 3 | API | Rate limit or server error |
| 4 | Data | Symbol not found |
| 5 | Config | Configuration error |
| 6 | Output | File write error |
Reporting Issues
When reporting issues, include:
Command executed:
python price_tracker.py --symbol XYZ --verboseFull error output (with
--verboseflag)Python version:
python --versionPackage versions:
pip show requests yfinance pandasConfiguration (redact API keys):
cat config/settings.yaml