Protect the main loop with a generic try/except.