Restructured try/except block for recording setup