Improve API validation error messages with helpful instructions instead of traceback

This commit is contained in:
justin committed 2026-01-27 17:32:34 -07:00
1 parent 564f4e25e6
commit 65514ade82
1 file changed
+10 -4
+10 -4
View File
@@ -1356,10 +1356,16 @@ def main():
logger.info(f"✅ Clock access verified - Market is {'OPEN' if clock.is_open else 'CLOSED'}") logger.info(f"✅ Clock access verified - Market is {'OPEN' if clock.is_open else 'CLOSED'}")
except Exception as e: except Exception as e:
logger.error(f"❌ API validation failed: {e}") error_msg = str(e).lower()
logger.error(" Please check your API credentials in .env file") logger.error(f"❌ API validation failed")
import traceback
logger.error(traceback.format_exc()) if 'unauthorized' in error_msg or 'forbidden' in error_msg:
logger.error(f"🔑 Invalid API credentials detected")
logger.error(f"Please update your .env file with valid API keys")
else:
logger.error(f"Error: {e}")
logger.error(f"Please check your .env file and network connection")
return return
# Run backtest once at startup # Run backtest once at startup