Replace try/except with proper response code checking.