fixed exception handler in main.py