add error handling to app.py