Improve error handling in cronjobs.py