Files
fquiz/api/verify_debug_mode.py
T
chengkai3 3cc35c0336 feat: [FL-184] 添加调试模式配置以返回异常堆栈跟踪
- 在配置文件中添加 debug_mode 参数,默认值为 true
- 创建全局异常处理器,当 debug_mode 开启时返回 stacktrace 信息
- 在 .env.example 中添加 DEBUG_MODE 配置项说明
- 新增测试文件验证调试模式功能

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
2026-06-18 08:39:21 +08:00

46 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""Verify debug mode configuration and exception handler."""
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "app"))
from app.core.config import get_settings
def main():
settings = get_settings()
print("Configuration Verification:")
print(f" debug_mode: {settings.debug_mode}")
print(f" api_name: {settings.api_name}")
print(f" api_version: {settings.api_version}")
# Test exception handler import
try:
from app.core.exception_handlers import global_exception_handler
print("\n✓ Exception handler imported successfully")
except ImportError as e:
print(f"\n✗ Failed to import exception handler: {e}")
return 1
# Test main app import
try:
from app.main import app
print("✓ Main app imported successfully")
# Check if exception handler is registered
exception_handlers = app.exception_handlers
if Exception in exception_handlers:
print("✓ Global exception handler is registered")
else:
print("✗ Global exception handler is NOT registered")
return 1
except ImportError as e:
print(f"✗ Failed to import main app: {e}")
return 1
print("\n✓ All checks passed!")
return 0
if __name__ == "__main__":
sys.exit(main())