You can catch the BadZipFile exception to handle corrupted or invalid zip files. This allows you to print an error message or take some other corrective action.