error handling in main loop. traceback in log if necessary.